got rid of some unnecessary regex in the fixtures function

This commit is contained in:
ronnyabraham 2020-08-31 20:16:33 +03:00
parent f64b235eae
commit 15370c4a28

View file

@ -52,11 +52,11 @@ def commandline(args="", workingdir=None):
args=args, args=args,
djangosettings=configuration.imports.settings,) djangosettings=configuration.imports.settings,)
else: else:
commandline = "{djangoroot}/manage.py {args} --pythonpath='{djangoroot}'" \ commandline = "{djangoroot}/manage.py {args} --pythonpath='"\
" --settings={djangosettings}".format( "{djangoroot}' --settings={djangosettings}".format(
djangoroot=configuration.paths.django.root, djangoroot=configuration.paths.django.root,
args=args, args=args,
djangosettings=configuration.imports.settings,) djangosettings=configuration.imports.settings,)
print(commandline) print(commandline)
@ -89,11 +89,12 @@ def manage(args="", workingdir=None):
shell='/bin/bash') shell='/bin/bash')
with cd(configuration.paths.django.root): with cd(configuration.paths.django.root):
cmd = "{djangoroot}/manage.py {args} --pythonpath='{djangoroot}' " \ cmd = "{djangoroot}/manage.py {args} " \
"--settings={djangosettings}".format( " --pythonpath='{djangoroot}' " \
djangoroot=configuration.paths.django.root, "--settings={djangosettings}".format(
args=args, djangoroot=configuration.paths.django.root,
djangosettings=configuration.imports.settings,) args=args,
djangosettings=configuration.imports.settings,)
if env.debug: if env.debug:
print("command: with cd(%s)" % configuration.paths.django.root) print("command: with cd(%s)" % configuration.paths.django.root)
@ -282,12 +283,13 @@ def create_project():
project_path_old = "{project_path}/{project_name}.old".format( project_path_old = "{project_path}/{project_name}.old".format(
project_path=project_path, project_path=project_path,
project_name=project_name) project_name=project_name)
if exists(project_path_old): if exists(project_path_old):
prompt_continue( prompt_continue(
message="found an already existing old version of " message="found an already existing old "
"{project_path}, do you want to ignore backing up the version or exit? Y/n" "version of {project_path}, do you want to ignore"
"( Y to continue without backing up. N to exit )", default="n") " backing up the version or exit? Y/n ( Y to "
"continue without backing up. N to exit )", default="n")
fabric_ops.run("rm -Rf {project_path}/{project_name}".format( fabric_ops.run("rm -Rf {project_path}/{project_name}".format(
project_name=project_name, project_name=project_name,
@ -880,7 +882,7 @@ def fixtures(appname=None, backup=False):
try: try:
pos = match.end() pos = match.end()
output = output[pos:] output = output[pos:]
except: except Exception:
pass pass
# now find the first occurence of [ on a newline, e.g. # now find the first occurence of [ on a newline, e.g.
@ -889,12 +891,12 @@ def fixtures(appname=None, backup=False):
# "model.auth": 40, # "model.auth": 40,
# etc. # etc.
p = re.compile(r"\n\[") # p = re.compile(r"\n\[")
m = p.search(output) # m = p.search(output)
pos = m.end() - 1 # pos = m.end() - 1
output = output[pos:] # output = output[pos:]
from StringIO import StringIO from io import StringIO
fixture_iostring = StringIO(output) fixture_iostring = StringIO(output)
fabric_ops.put(fixture_iostring, path_fixture) fabric_ops.put(fixture_iostring, path_fixture)