Exemplo n.º 1
0
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)
Exemplo n.º 2
0
        rv.sort()
        print ' '.join(rv)

templatetools.handle_additional_parameters(sys.argv, help, shell_completion, usage=usage)

for_extras = False
i = 0

while i < len(sys.argv):
    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:
Exemplo n.º 3
0
project = None
ppa_name = None
i = 0
args = []
argv = sys.argv

while i < len(argv):
    arg = argv[i]
    if arg.startswith('-'):
        if arg == '--ppa':
            if i + 1 < len(argv):
                ppa_name = argv[i + 1]
                i += 1
            else:
                cmd = commands.get_command('submitubuntu', 'ubuntu-application')
                templatetools.usage_error(_("No PPA provided."), cmd=cmd)
        else:
            cmd = commands.get_command('submitubuntu', 'ubuntu-application')
            templatetools.usage_error(_("Unknown option: %s."  % arg), cmd=cmd)
    else:
        args.append(arg)
    i += 1

    commit_msg = None
if len(args) == 1:
    proposed_version = None
elif len(args) == 2:
    proposed_version = args[1]
elif len(args) > 2:
    proposed_version = args[1]
    commit_msg = " ".join(args[2:])
Exemplo n.º 4
0
        quicklyutils.change_xml_elem(
            about_dialog_file_name, "object/property", "name", "license", license_content, {"translatable": "yes"}
        )
    copy_license_to_files(license_content)


def shell_completion(argv):
    """Propose available license as the third parameter"""

    # if then license argument given, returns available licenses
    if len(argv) == 1:
        rv = get_supported_licenses()
        rv.sort()
        print " ".join(rv)


if __name__ == "__main__":

    templatetools.handle_additional_parameters(sys.argv, help, shell_completion, usage=usage)
    license = None
    if len(sys.argv) > 2:
        cmd = commands.get_command("license", "git-python-gtk")
        templatetools.usage_error(_("This command only take one optional argument."), cmd=cmd)
    if len(sys.argv) == 2:
        license = sys.argv[1]
    try:
        licensing(license)
    except LicenceError, error_message:
        print (error_message)
        sys.exit(1)
Exemplo n.º 5
0
project = None
ppa_name = None
i = 0
args = []
argv = sys.argv

while i < len(argv):
    arg = argv[i]
    if arg.startswith('-'):
        if arg == '--ppa':
            if i + 1 < len(argv):
                ppa_name = argv[i + 1]
                i += 1
            else:
                cmd = commands.get_command('submitubuntu', 'git-python-gtk')
                templatetools.usage_error(_("No PPA provided."), cmd=cmd)
        else:
            cmd = commands.get_command('submitubuntu', 'git-python-gtk')
            templatetools.usage_error(_("Unknown option: %s." % arg), cmd=cmd)
    else:
        args.append(arg)
    i += 1

    commit_msg = None
if len(args) == 1:
    proposed_version = None
elif len(args) == 2:
    proposed_version = args[1]
elif len(args) > 2:
    proposed_version = args[1]
    commit_msg = " ".join(args[2:])
Exemplo n.º 6
0
            pass
    help_text = "\n\n".join(help_list)
    print help_text


def shell_completion(argv):
    """ Complete args """
    # option completion
    rv = []
    if len(argv) == 1:
        rv = options.keys()
    if rv:
        rv.sort()
        print " ".join(rv)


templatetools.handle_additional_parameters(sys.argv, help, shell_completion, usage=usage)

if len(sys.argv) < 2:
    cmd = commands.get_command("add", "git-python-gtk")
    templatetools.usage_error(_("Cannot add, no plugin name provided."), cmd=cmd, template="git-python-gtk")

if argv[1] in ADDABLE.keys():
    ADDABLE[argv[1]].add(options)
else:
    cmd = commands.get_command("add", "git-python-gtk")
    templatetools.usage_error(
        _("Cannot add, did not recognize plugin name: %s" % argv[1]), cmd=cmd, template="git-python-gtk"
    )
    sys.exit(4)
Exemplo n.º 7
0
templatetools.handle_additional_parameters(sys.argv,
                                           help,
                                           shell_completion,
                                           usage=usage)

for_extras = False
i = 0

while i < len(sys.argv):
    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")
Exemplo n.º 8
0
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)
Exemplo n.º 9
0

def shell_completion(argv):
    """Propose available license as the third parameter"""

    # if then license argument given, returns available licenses
    if len(argv) == 1:
        rv = get_supported_licenses()
        rv.sort()
        print ' '.join(rv)


if __name__ == "__main__":

    templatetools.handle_additional_parameters(sys.argv,
                                               help,
                                               shell_completion,
                                               usage=usage)
    license = None
    if len(sys.argv) > 2:
        cmd = commands.get_command('license', 'ubuntu-application')
        templatetools.usage_error(
            _("This command only take one optional argument."), cmd=cmd)
    if len(sys.argv) == 2:
        license = sys.argv[1]
    try:
        licensing(license)
    except LicenceError, error_message:
        print(error_message)
        sys.exit(1)
Exemplo n.º 10
0
    for module in ADDABLE.values():
        try:
            help_list.append(module.help_text)
        except AttributeError:
            # ignore files in store that have no help for us
            pass
    help_text = '\n\n'.join(help_list)
    print help_text

def shell_completion(argv):
    ''' Complete args '''
    # option completion
    rv = []
    if len(argv) == 1:
        rv = options.keys()
    if rv:
        rv.sort()
        print ' '.join(rv)
templatetools.handle_additional_parameters(sys.argv, help, shell_completion, usage=usage)

if len(sys.argv) < 2:
    cmd = commands.get_command('add', 'ubuntu-application')
    templatetools.usage_error(_("Cannot add, no plugin name provided."), cmd=cmd, template='ubuntu-application')

if argv[1] in ADDABLE.keys():
    ADDABLE[argv[1]].add(options)
else:
    cmd = commands.get_command('add', 'ubuntu-application')
    templatetools.usage_error(_('Cannot add, did not recognize plugin name: %s' % argv[1]), cmd=cmd, template='ubuntu-application')
    sys.exit(4)
Exemplo n.º 11
0
    ''' Complete args '''
    # option completion
    rv = []
    if len(argv) == 1:
        rv = options.keys()
    if rv:
        rv.sort()
        print ' '.join(rv)


templatetools.handle_additional_parameters(sys.argv,
                                           help,
                                           shell_completion,
                                           usage=usage)

if len(sys.argv) < 2:
    cmd = commands.get_command('add', 'git-python-gtk')
    templatetools.usage_error(_("Cannot add, no plugin name provided."),
                              cmd=cmd,
                              template='git-python-gtk')

if argv[1] in ADDABLE.keys():
    ADDABLE[argv[1]].add(options)
else:
    cmd = commands.get_command('add', 'git-python-gtk')
    templatetools.usage_error(_(
        'Cannot add, did not recognize plugin name: %s' % argv[1]),
                              cmd=cmd,
                              template='git-python-gtk')
    sys.exit(4)
Exemplo n.º 12
0
    ''' Complete args '''
    # option completion
    rv = []
    if len(argv) == 1:
        rv = options.keys()
    if rv:
        rv.sort()
        print ' '.join(rv)


templatetools.handle_additional_parameters(sys.argv,
                                           help,
                                           shell_completion,
                                           usage=usage)

if len(sys.argv) < 2:
    cmd = commands.get_command('add', 'ubuntu-application')
    templatetools.usage_error(_("Cannot add, no plugin name provided."),
                              cmd=cmd,
                              template='ubuntu-application')

if argv[1] in ADDABLE.keys():
    ADDABLE[argv[1]].add(options)
else:
    cmd = commands.get_command('add', 'ubuntu-application')
    templatetools.usage_error(_(
        'Cannot add, did not recognize plugin name: %s' % argv[1]),
                              cmd=cmd,
                              template='ubuntu-application')
    sys.exit(4)