mirror of https://github.com/cheat/cheat.git
Resolved merge-conflict.
This commit is contained in:
commit
f000756f2c
|
@ -31,8 +31,8 @@ Options:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# require the dependencies
|
# require the dependencies
|
||||||
from cheat import *
|
from cheat import sheets, sheet
|
||||||
from cheat.utils import *
|
from cheat.utils import colorize
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
from cheat import sheets
|
|
||||||
from cheat import utils
|
|
||||||
from cheat.utils import *
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from cheat import sheets
|
||||||
|
from cheat.utils import die, editor
|
||||||
|
|
||||||
def copy(current_sheet_path, new_sheet_path):
|
def copy(current_sheet_path, new_sheet_path):
|
||||||
""" Copies a sheet to a new path """
|
""" Copies a sheet to a new path """
|
||||||
|
@ -16,7 +15,7 @@ def copy(current_sheet_path, new_sheet_path):
|
||||||
# fail gracefully if the cheatsheet cannot be copied. This can happen if
|
# fail gracefully if the cheatsheet cannot be copied. This can happen if
|
||||||
# DEFAULT_CHEAT_DIR does not exist
|
# DEFAULT_CHEAT_DIR does not exist
|
||||||
except IOError:
|
except IOError:
|
||||||
die ('Could not copy cheatsheet for editing.')
|
die('Could not copy cheatsheet for editing.')
|
||||||
|
|
||||||
|
|
||||||
def create_or_edit(sheet):
|
def create_or_edit(sheet):
|
||||||
|
@ -84,5 +83,5 @@ def read(sheet):
|
||||||
if not exists(sheet):
|
if not exists(sheet):
|
||||||
die('No cheatsheet found for ' + sheet)
|
die('No cheatsheet found for ' + sheet)
|
||||||
|
|
||||||
with open (path(sheet)) as cheatfile:
|
with open(path(sheet)) as cheatfile:
|
||||||
return cheatfile.read()
|
return cheatfile.read()
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from cheat import cheatsheets
|
|
||||||
from cheat.utils import *
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from cheat import cheatsheets
|
||||||
|
from cheat.utils import die
|
||||||
|
|
||||||
def default_path():
|
def default_path():
|
||||||
""" Returns the default cheatsheet path """
|
""" Returns the default cheatsheet path """
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ def default_path():
|
||||||
if not os.access(default_sheets_dir, os.R_OK):
|
if not os.access(default_sheets_dir, os.R_OK):
|
||||||
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not readable.')
|
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not readable.')
|
||||||
if not os.access(default_sheets_dir, os.W_OK):
|
if not os.access(default_sheets_dir, os.W_OK):
|
||||||
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not writeable.')
|
die('The DEFAULT_CHEAT_DIR (' + default_sheets_dir +') is not writable.')
|
||||||
|
|
||||||
# return the default dir
|
# return the default dir
|
||||||
return default_sheets_dir
|
return default_sheets_dir
|
||||||
|
@ -81,10 +82,10 @@ def search(term):
|
||||||
for cheatsheet in sorted(get().items()):
|
for cheatsheet in sorted(get().items()):
|
||||||
match = ''
|
match = ''
|
||||||
for line in open(cheatsheet[1]):
|
for line in open(cheatsheet[1]):
|
||||||
if term in line:
|
if term in line:
|
||||||
match += ' ' + line
|
match += ' ' + line
|
||||||
|
|
||||||
if not match == '':
|
if match != '':
|
||||||
result += cheatsheet[0] + ":\n" + match + "\n"
|
result += cheatsheet[0] + ":\n" + match + "\n"
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -38,14 +38,13 @@ def editor():
|
||||||
|
|
||||||
elif os.environ['EDITOR'] == "":
|
elif os.environ['EDITOR'] == "":
|
||||||
die(
|
die(
|
||||||
'Your EDITOR environment variable is set to an empty string. It must '
|
'Your EDITOR environment variable is set to an empty string. It must '
|
||||||
'be set to your editor\'s path.'
|
'be set to your editor\'s path.'
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return os.environ['EDITOR']
|
return os.environ['EDITOR']
|
||||||
|
|
||||||
|
|
||||||
def warn(message):
|
def warn(message):
|
||||||
""" Prints a message to stderr """
|
""" Prints a message to stderr """
|
||||||
print((message), file=sys.stderr)
|
print((message), file=sys.stderr)
|
||||||
|
|
Loading…
Reference in New Issue