Skip to content

Commit

Permalink
Remove trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jiri-janousek committed May 9, 2018
1 parent 7a5f4bc commit ba6c9fb
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 66 deletions.
10 changes: 5 additions & 5 deletions nuvolasdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Copyright 2016 Jiří Janoušek <[email protected]>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand Down Expand Up @@ -59,7 +59,7 @@ def print_help(prog):
print('\nCreate addon data XML')
print('====================\n')
nuvolasdk.addondata.create_arg_parser(prog + " create-addondata").print_help()

def run(wd, argv):
prog = os.path.basename(argv[0])
if prog.startswith("__main__"):
Expand All @@ -84,7 +84,7 @@ def run(wd, argv):
if cmd in ('-h', '--help', 'help'):
print_help(prog)
return 0

print("Error: Unknown command '%s'.\n" % cmd)
print_help(prog)
return 2
48 changes: 24 additions & 24 deletions nuvolasdk/checkproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Copyright 2016-2018 Jiří Janoušek <[email protected]>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand Down Expand Up @@ -41,36 +41,36 @@ def run(directory, prog, argv):
sdk_data = utils.get_sdk_data_dir()
pushdir(directory)
n_errors = 0

if fexists("Makefile"):
print("Cleaning the project...")
try_run('make clean')
print("")

print("Checking the project...")

F_METADATA_IN_JSON = "metadata.in.json"
F_CONFIGURE = "configure"
F_CHANGELOG_MD = "CHANGELOG.md"
F_README_MD = "README.md"
F_CONTRIBUTING_MD = "CONTRIBUTING.md"
F_INTEGRATE_JS = "integrate.js"
F_GITIGNORE = ".gitignore"

files = (
F_METADATA_IN_JSON, F_INTEGRATE_JS, F_CONFIGURE,
F_CHANGELOG_MD, F_README_MD, F_CONTRIBUTING_MD, F_GITIGNORE
)

for filename in files:
if not fexists(filename):
print("Error: A file '%s' is missing." % filename)
n_errors += 1

if not utils.get_license_files():
print("Error: No license files (LICENSE*) have been found.")
n_errors += 1

METADATA_JSON = "metadata.json"
if fexists(F_METADATA_IN_JSON):
metadata = readjson(F_METADATA_IN_JSON)
Expand All @@ -82,7 +82,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "id" property.')
n_errors += 1

try:
app_name = metadata["name"].strip()
if not app_name:
Expand All @@ -91,7 +91,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "name" property.')
n_errors += 1

prop_name = "version_major"
try:
version_major = metadata[prop_name]
Expand All @@ -101,7 +101,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "version_minor"
try:
version_minor = metadata[prop_name]
Expand All @@ -111,7 +111,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "api_major"
try:
api_major = metadata[prop_name]
Expand All @@ -121,7 +121,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "api_minor"
try:
api_minor = metadata[prop_name]
Expand All @@ -131,7 +131,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "maintainer_link"
try:
maintainer_link = metadata[prop_name]
Expand All @@ -141,7 +141,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "maintainer_name"
try:
maintainer_name = metadata[prop_name]
Expand All @@ -151,7 +151,7 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "license"
try:
license = metadata[prop_name]
Expand All @@ -170,11 +170,11 @@ def run(directory, prog, argv):
licenses.check_canonical(license)
except ValueError as e:
print('Warning: "{}" is not a canonical SPDX license name, use "{}" instead.'.format(*e.args))

except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % prop_name)
n_errors += 1

prop_name = "categories"
try:
categories = metadata[prop_name]
Expand All @@ -184,9 +184,9 @@ def run(directory, prog, argv):
except KeyError:
print('Error: metadata.json file must contain the "%s" property.' % categories)
n_errors += 1



try:
build = metadata["build"]
try:
Expand Down Expand Up @@ -237,4 +237,4 @@ def run(directory, prog, argv):

print("No errors have been found.")
return 0

44 changes: 22 additions & 22 deletions nuvolasdk/convertproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Copyright 2014-2018 Jiří Janoušek <[email protected]>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand Down Expand Up @@ -36,22 +36,22 @@ def create_arg_parser(prog):
description = 'Converts an old-style project to a SDK project.'
)
return parser

def convert_project(directory, prog, argv):
args = create_arg_parser(prog).parse_args(argv)
sdk_data = utils.get_sdk_data_dir()
pushdir(directory)
build_extra_data = []
todos = []
git_commands = []

try:
git.set_up_git()
except KeyboardInterrupt:
return 1
except ExecError as e:
print("Error: Failed to set up git. %s" % e)

MAKEFILE = "Makefile"
makefile = joinpath(directory, MAKEFILE)
if fexists(makefile) and not fexists(makefile + ".old"):
Expand All @@ -68,7 +68,7 @@ def convert_project(directory, prog, argv):
entry = entry.strip()
if entry and entry not in defaults.BASE_INSTALL_FILES:
extra_data.append(entry)

if backup_makefile:
build_extra_data.extend(extra_data)
print("Making a backup of the Makefile")
Expand All @@ -77,14 +77,14 @@ def convert_project(directory, prog, argv):
todos.append("If the script builds, remove the Makefile.old file.")
except FileNotFoundError as e:
pass


METADATA_JSON = "metadata.json"
metadata_in = "metadata.in.json"
if fexists(METADATA_JSON) and not fexists(metadata_in):
print("Renaming %s to %s" % (METADATA_JSON, metadata_in))
rename(METADATA_JSON, metadata_in)

metadata = readjson(metadata_in)
metadata_changed = False
try:
Expand All @@ -95,7 +95,7 @@ def convert_project(directory, prog, argv):
app_name = metadata["name"]
except KeyError:
raise ValueError('Error: metadata.json file must contain the "name" property.')

try:
version_major = metadata["version_major"]
except KeyError:
Expand All @@ -112,7 +112,7 @@ def convert_project(directory, prog, argv):
maintainer_link = metadata["maintainer_link"]
except KeyError:
raise ValueError('Error: metadata.json file must contain the "maintainer_link" property.')

try:
license = metadata["license"]
except KeyError:
Expand All @@ -122,15 +122,15 @@ def convert_project(directory, prog, argv):
license = input(prompt).strip()
metadata["license"] = license
metadata_changed = True

subst = {
"maintainer_name": maintainer_name,
"year": datetime.date.today().year,
"app_id": app_id,
"app_id_dashed": utils.get_dashed_app_id(app_id),
"app_name": app_name,
}

try:
build = metadata["build"]
except KeyError:
Expand All @@ -139,7 +139,7 @@ def convert_project(directory, prog, argv):
metadata["build"]["extra_data"] = build_extra_data
print("Adding the build section to metadata.in.json")
metadata_changed = True

if metadata_changed:
writejson(metadata_in, metadata)
else:
Expand All @@ -153,7 +153,7 @@ def convert_project(directory, prog, argv):
configure = joinpath(directory, "configure")
fwrite(configure, defaults.CONFIGURE_SCRIPT)
fchmod(configure, fstat(configure).st_mode|0o111)

F_CHANGELOG_MD = "CHANGELOG.md"
if not fexists(F_CHANGELOG_MD):
print("Generating", F_CHANGELOG_MD)
Expand All @@ -166,14 +166,14 @@ def convert_project(directory, prog, argv):
changelog.append(" * Ported to use Nuvola SDK.")
with open(F_CHANGELOG_MD, "wt", encoding="utf-8") as f:
f.write("\n".join(changelog) + "\n")

F_CONTRIBUTING_MD = "CONTRIBUTING.md"
if not fexists(F_CONTRIBUTING_MD):
print("Generating", F_CONTRIBUTING_MD)
todos.append("Revise the content of the auto-generated file %s." % F_CONTRIBUTING_MD)
cp(joinpath(sdk_data, "template", F_CONTRIBUTING_MD), F_CONTRIBUTING_MD)
dollar_replace(F_CONTRIBUTING_MD, subst)

F_README_MD = "README.md"
if not fexists(F_README_MD):
readme_md_to_substitute = F_README_MD
Expand Down Expand Up @@ -244,18 +244,18 @@ def convert_project(directory, prog, argv):
del(gitignore[-1])
except Exception:
gitignore = []

expected_rules = set(s for s in utils.get_gitignore_for_app_id(app_id).splitlines() if s)
for rule in gitignore:
expected_rules.discard(rule)

if expected_rules:
for rule in sorted(expected_rules):
gitignore.append(rule)
gitignore.append("")
print("Updating .gitignore")
fwrite(GITIGNORE, "\n".join(gitignore))

print("Trying to update git repo")
try_run('git add metadata.in.json')
try_run('git add configure')
Expand All @@ -269,7 +269,7 @@ def convert_project(directory, prog, argv):
try_run('git rm -f --cached svg-optimize.sh')
for cmd in git_commands:
try_run(cmd)

print("Finished!")
print("\nTasks to do:\n")
for todo in todos:
Expand Down
Loading

0 comments on commit ba6c9fb

Please sign in to comment.