Ejemplo n.º 1
0
 def test_smoke(self):
     proj = {'setup.cfg': textwrap.dedent(u"""
         [extras]
         1 =
           foo
         2 =
           foo # fred
           bar
         """)}
     expected = {
         '1': '\nfoo',
         '2': '\nfoo # fred\nbar'
     }
     self.assertEqual(expected, project.extras(proj))
Ejemplo n.º 2
0
def _copy_requires(suffix,
                   softupdate,
                   hacking,
                   proj,
                   global_reqs,
                   non_std_reqs,
                   blacklist={}):
    """Copy requirements files."""
    actions = []
    for source, content in sorted(proj['requirements'].items()):
        dest_path = os.path.join(proj['root'], source)
        # this is specifically for global-requirements gate jobs so we don't
        # modify the git tree
        if suffix:
            dest_path = "%s.%s" % (dest_path, suffix)
            dest_name = "%s.%s" % (source, suffix)
        else:
            dest_name = source
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing %s" % dest_path))
        _actions, reqs = _sync_requirements_file(global_reqs, dest_sequence,
                                                 dest_path, softupdate,
                                                 hacking, non_std_reqs,
                                                 blacklist)
        actions.extend(_actions)
        actions.append(project.File(dest_name, requirement.to_content(reqs)))
    extras = project.extras(proj)
    output_extras = {}
    for extra, content in sorted(extras.items()):
        dest_name = 'extra-%s' % extra
        dest_path = "%s[%s]" % (proj['root'], extra)
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing extra [%s]" % extra))
        _actions, reqs = _sync_requirements_file(global_reqs, dest_sequence,
                                                 dest_path, softupdate,
                                                 hacking, non_std_reqs,
                                                 blacklist)
        actions.extend(_actions)
        output_extras[extra] = reqs
    dest_path = 'setup.cfg'
    if suffix:
        dest_path = "%s.%s" % (dest_path, suffix)
    actions.append(
        project.File(dest_path,
                     project.merge_setup_cfg(proj['setup.cfg'],
                                             output_extras)))
    return actions
Ejemplo n.º 3
0
    def process(self, strict=True):
        """Convert the project into ready to use data.

        - an iterable of requirement sets to check
        - each set has the following rules:
          - each has a list of Requirements objects
          - duplicates are not permitted within that list
        """
        print("Checking %(name)s" % {'name': self.name})
        # First, parse.
        for fname, content in self.project.get('requirements', {}).items():
            print("Processing %(fname)s" % {'fname': fname})
            if strict and not content.endswith('\n'):
                print("Requirements file %s does not "
                      "end with a newline." % fname)
            self.reqs_by_file[fname] = self.extract_reqs(content, strict)

        for name, content in project.extras(self.project).items():
            print("Processing .[%(extra)s]" % {'extra': name})
            self.reqs_by_file[name] = self.extract_reqs(content, strict)
Ejemplo n.º 4
0
    def process(self, strict=True):
        """Convert the project into ready to use data.

        - an iterable of requirement sets to check
        - each set has the following rules:
          - each has a list of Requirements objects
          - duplicates are not permitted within that list
        """
        print("Checking %(name)s" % {'name': self.name})
        # First, parse.
        for fname, content in self.project.get('requirements', {}).items():
            print("Processing %(fname)s" % {'fname': fname})
            if strict and not content.endswith('\n'):
                print("Requirements file %s does not "
                      "end with a newline." % fname)
            self.reqs_by_file[fname] = self.extract_reqs(content, strict)

        for name, content in project.extras(self.project).items():
            print("Processing .[%(extra)s]" % {'extra': name})
            self.reqs_by_file[name] = self.extract_reqs(content, strict)
Ejemplo n.º 5
0
def _copy_requires(
        suffix, softupdate, hacking, proj, global_reqs, non_std_reqs,
        blacklist={}):
    """Copy requirements files."""
    actions = []
    for source, content in sorted(proj['requirements'].items()):
        dest_path = os.path.join(proj['root'], source)
        # this is specifically for global-requirements gate jobs so we don't
        # modify the git tree
        if suffix:
            dest_path = "%s.%s" % (dest_path, suffix)
            dest_name = "%s.%s" % (source, suffix)
        else:
            dest_name = source
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing %s" % dest_path))
        _actions, reqs = _sync_requirements_file(
            global_reqs, dest_sequence, dest_path, softupdate, hacking,
            non_std_reqs, blacklist)
        actions.extend(_actions)
        actions.append(project.File(dest_name, requirement.to_content(reqs)))
    extras = project.extras(proj)
    output_extras = {}
    for extra, content in sorted(extras.items()):
        dest_name = 'extra-%s' % extra
        dest_path = "%s[%s]" % (proj['root'], extra)
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing extra [%s]" % extra))
        _actions, reqs = _sync_requirements_file(
            global_reqs, dest_sequence, dest_path, softupdate, hacking,
            non_std_reqs, blacklist)
        actions.extend(_actions)
        output_extras[extra] = reqs
    dest_path = 'setup.cfg'
    if suffix:
        dest_path = "%s.%s" % (dest_path, suffix)
    actions.append(project.File(
        dest_path, project.merge_setup_cfg(proj['setup.cfg'], output_extras)))
    return actions
Ejemplo n.º 6
0
 def test_no_setup_cfg(self):
     proj = {}
     self.assertEqual({}, project.extras(proj))
Ejemplo n.º 7
0
 def test_none(self):
     proj = {'setup.cfg': u"[metadata]\n"}
     self.assertEqual({}, project.extras(proj))