def licensing(license=None): """Add license or update it to the project files Default is GPL-3""" fauthors_name = "AUTHORS" flicense_name = "COPYING" if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] python_name = templatetools.python_name(project_name) # check if we have a license tag in setup.py otherwise, default to GPL-3 if not license: try: license = quicklyutils.get_setup_value('license') except quicklyutils.cant_deal_with_setup_value: pass if not license: license = guess_license(flicense_name) if license == 'other': msg = _("COPYING contains an unknown license. Please run 'quickly license other' to confirm that you want to use a custom license.") raise LicenceError(msg) if not license: license = 'GPL-3' supported_licenses_list = get_supported_licenses() supported_licenses_list.sort() if license not in supported_licenses_list and license != 'other': cmd = commands.get_command('license', 'ubuntu-application') templatetools.usage_error(_("Unknown licence %s.") % license, cmd=cmd) # get Copyright holders in AUTHORS file license_content = "" try: for line in file(fauthors_name, 'r'): if "<Your Name> <Your E-mail>" in line: # if we have an author in setup.py, grab it try: author = quicklyutils.get_setup_value('author') author_email = quicklyutils.get_setup_value('author_email') line = "Copyright (C) %s %s <%s>\n" % (datetime.datetime.now().year, author, author_email) # update AUTHORS file fout = file('%s.new' % fauthors_name, 'w') fout.write(line) fout.flush() fout.close() os.rename(fout.name, fauthors_name) except quicklyutils.cant_deal_with_setup_value: msg = _('Copyright is not attributed. ' \ 'Edit the AUTHORS file to include your name for the copyright replacing ' \ '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \ 'to fill it automatically') raise LicenceError(msg) license_content += "# %s" % line except (OSError, IOError), e: msg = _("%s file was not found") % fauthors_name raise LicenceError(msg)
arg = sys.argv[i] if arg.startswith('-'): if arg == '--extras': for_extras = True else: cmd = commands.get_command('package', 'ubuntu-application') templatetools.usage_error(_("Unknown option: %s." % arg), cmd=cmd) i += 1 # retrieve useful information if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] try: release_version = quicklyutils.get_setup_value('version') except quicklyutils.cant_deal_with_setup_value: print _("Release version not found in setup.py.") # creation/update debian packaging if packaging.updatepackaging(no_changelog=True, installopt=for_extras) != 0: print _("ERROR: can't create or update ubuntu package") sys.exit(1) # creating local binary package return_code = packaging.filter_exec_command(["dpkg-buildpackage", "-tc", "-I.bzr", "-us", "-uc"]) if return_code == 0:
def updateversion(proposed_version=None, sharing=False): """Update versioning with year.month, handling intermediate release""" if proposed_version: # check manual versionning is correct try: for number in proposed_version.split("."): float(number) except ValueError: msg = _("Release version specified in command arguments is not a " "valid version scheme like 'x(.y)(.z)'.") raise invalid_versionning_scheme(msg) new_version = proposed_version else: # get previous value try: old_version = quicklyutils.get_setup_value("version") except quicklyutils.cant_deal_with_setup_value: msg = _("No previous version found in setup.py. Put one please") raise invalid_version_in_setup(msg) # sharing only add -publicX to last release, no other update, no bumping if sharing: splitted_release_version = old_version.split("-public") if len(splitted_release_version) > 1: try: share_version = float(splitted_release_version[1]) except ValueError: msg = ( _("Share version specified after -public in " "setup.py is not a valid number: %s") % splitted_release_version[1] ) raise invalid_versionning_scheme(msg) new_version = splitted_release_version[0] + "-public" + str(int(share_version + 1)) else: new_version = old_version + "-public1" # automatically version to year.month(.subversion) else: base_version = datetime.datetime.now().strftime("%y.%m") if base_version in old_version: try: # try to get a minor version, removing -public if one (year, month, minor_version) = old_version.split(".") minor_version = minor_version.split("-public")[0] try: minor_version = float(minor_version) except ValueError: msg = ( _( "Minor version specified in setup.py is not a " "valid number: %s. Fix this or specify a " "version as release command line argument" ) % minor_version ) raise invalid_versionning_scheme(msg) new_version = base_version + "." + str(int(minor_version + 1)) except ValueError: # no minor version, bump to first one (be careful, # old_version may contain -publicX) new_version = base_version + ".1" else: # new year/month new_version = base_version # write release version to setup.py and update it in aboutdialog quicklyutils.set_setup_value("version", new_version) about_dialog_file_name = quicklyutils.get_about_file_name() if about_dialog_file_name: quicklyutils.change_xml_elem(about_dialog_file_name, "object/property", "name", "version", new_version, {}) return new_version
arg = sys.argv[i] if arg.startswith('-'): if arg == '--extras': for_extras = True else: cmd = commands.get_command('package', 'git-python-gtk') templatetools.usage_error(_("Unknown option: %s." % arg), cmd=cmd) i += 1 # retrieve useful information if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] try: release_version = quicklyutils.get_setup_value('version') except quicklyutils.cant_deal_with_setup_value: print _("Release version not found in setup.py.") # creation/update debian packaging if packaging.updatepackaging(no_changelog=True, installopt=for_extras) != 0: print _("ERROR: can't create or update ubuntu package") sys.exit(1) # creating local binary package return_code = packaging.filter_exec_command( ["dpkg-buildpackage", "-tc", "-I.git", "-us", "-uc"]) if return_code == 0: print _("Ubuntu package has been successfully created in ../%s_%s_all.deb" ) % (project_name, release_version)
fauthor_out = file('AUTHORS.new', 'w') for line in file(source_file): if '### BEGIN AUTOMATIC LICENSE GENERATION' in line: break if line.startswith('#'): line = line[1:].lstrip() fauthor_out.write(line) fauthor_out.flush() fauthor_out.close() os.rename('AUTHORS.new', 'AUTHORS') os.remove('Copyright') except (OSError, IOError), e: pass # update config file to add __license__ try: license = quicklyutils.get_setup_value('license') except quicklyutils.cant_deal_with_setup_value: license = '' try: skip = 0 config_file = '%s/%sconfig.py' % (python_name, python_name) fin = file(config_file, 'r') fout = file(fin.name + '.new', 'w') license_found_in_file = False data_file_function_found = False for line in fin: if skip > 0: fout.write(line) skip -= 1 continue fields = line.split(' = ') # Separate variable from value
def licensing(license=None): """Add license or update it to the project files Default is GPL-3""" fauthors_name = "AUTHORS" flicense_name = "COPYING" if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] python_name = templatetools.python_name(project_name) # check if we have a license tag in setup.py otherwise, default to GPL-3 if not license: try: license = quicklyutils.get_setup_value('license') except quicklyutils.cant_deal_with_setup_value: pass if not license: license = guess_license(flicense_name) if license == 'other': msg = _( "COPYING contains an unknown license. Please run 'quickly license other' to confirm that you want to use a custom license." ) raise LicenceError(msg) if not license: license = 'GPL-3' supported_licenses_list = get_supported_licenses() supported_licenses_list.sort() if license not in supported_licenses_list and license != 'other': cmd = commands.get_command('license', 'ubuntu-application') templatetools.usage_error(_("Unknown licence %s.") % license, cmd=cmd) # get Copyright holders in AUTHORS file license_content = "" try: for line in file(fauthors_name, 'r'): if "<Your Name> <Your E-mail>" in line: # if we have an author in setup.py, grab it try: author = quicklyutils.get_setup_value('author') author_email = quicklyutils.get_setup_value('author_email') line = "Copyright (C) %s %s <%s>\n" % ( datetime.datetime.now().year, author, author_email) # update AUTHORS file fout = file('%s.new' % fauthors_name, 'w') fout.write(line) fout.flush() fout.close() os.rename(fout.name, fauthors_name) except quicklyutils.cant_deal_with_setup_value: msg = _('Copyright is not attributed. ' \ 'Edit the AUTHORS file to include your name for the copyright replacing ' \ '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \ 'to fill it automatically') raise LicenceError(msg) license_content += "# %s" % line except (OSError, IOError), e: msg = _("%s file was not found") % fauthors_name raise LicenceError(msg)
def updateversion(proposed_version=None, sharing=False): '''Update versioning with year.month, handling intermediate release''' if proposed_version: # check manual versioning is correct try: for number in proposed_version.split('.'): float(number) except ValueError: msg = _("Release version specified in command arguments is not a " \ "valid version scheme like 'x(.y)(.z)'.") raise invalid_versionning_scheme(msg) new_version = proposed_version else: # get previous value try: old_version = quicklyutils.get_setup_value('version') except quicklyutils.cant_deal_with_setup_value: msg = _("No previous version found in setup.py. Put one please") raise invalid_version_in_setup(msg) # sharing only add -publicX to last release, no other update, no bumping if sharing: splitted_release_version = old_version.split("-public") if len(splitted_release_version) > 1: try: share_version = float(splitted_release_version[1]) except ValueError: msg = _("Share version specified after -public in "\ "setup.py is not a valid number: %s") \ % splitted_release_version[1] raise invalid_versionning_scheme(msg) new_version = splitted_release_version[0] + '-public' + \ str(int(share_version + 1)) else: new_version = old_version + "-public1" # automatically version to year.month(.subversion) else: base_version = datetime.datetime.now().strftime("%y.%m") if base_version in old_version: try: # try to get a minor version, removing -public if one (year, month, minor_version) = old_version.split('.') minor_version = minor_version.split('-public')[0] try: minor_version = float(minor_version) except ValueError: msg = _("Minor version specified in setup.py is not a " \ "valid number: %s. Fix this or specify a " \ "version as release command line argument") \ % minor_version raise invalid_versionning_scheme(msg) new_version = base_version + '.' + str(int(minor_version + 1)) except ValueError: # no minor version, bump to first one (be careful, # old_version may contain -publicX) new_version = base_version + '.1' else: # new year/month new_version = base_version # write release version to setup.py and update it in aboutdialog quicklyutils.set_setup_value('version', new_version) about_dialog_file_name = quicklyutils.get_about_file_name() if about_dialog_file_name: quicklyutils.change_xml_elem(about_dialog_file_name, "object/property", "name", "version", new_version, {}) return new_version