コード例 #1
0
ファイル: metadata.py プロジェクト: dhh1128/sandman
def get_components_inv_dep_order(working_repo,
                                 platform,
                                 top,
                                 code_root=None,
                                 branch='trunk',
                                 revision=None,
                                 aspect=component.CODE_ASPECT_NAME,
                                 debug=False,
                                 use_master=False,
                                 check_vcs=True):
    '''
    Return a list of components in inverse dependency order, using the specified
    component as the starting point of the dependency graph. Inverse dependency
    order means that the components with no dependencies (the leaves) are listed
    first, and the most dependent component is last. This is valid build order.

    @param top The name of the topmost component.
    @param code_root Optional. The fully qualified path to the code root of an
    existing sandbox. If specified, then the metadata.txt files for components
    in the coderoot are used to override/pre-empt the checked-in versions.
    @param branch The branch of the components. All components in the dependency
    tree must share this branch.
    @param revision The revision of the topmost component; None = latest.
    @param aspect The aspect of the topmost component.
    '''
    already_analyzed = {}
    comp = component.Component(top, branch, revision, aspect)
    dep_tree = _get_deps(working_repo, platform, comp, code_root,
                         {str(comp): comp}, already_analyzed, use_master,
                         check_vcs)
    # At this point dep_tree is a single Component object that has embedded child
    # nodes in its .dependencies member. If our topmost component is terminal,
    # we won't have buildscripts in the code folder unless we artificially
    # inject the dependency here...
    if not has_component(dep_tree, 'buildscripts'):
        c = component.Component('buildscripts',
                                dep_tree.branch,
                                None,
                                component.CODE_ASPECT_NAME,
                                parent=dep_tree)
        dep_tree.dependencies.append(c)

    if debug:
        tree = dep_tree
    _detect_conflicts(working_repo, dep_tree, branch, top, [], debug)
    components = _trim_tree(dep_tree)
    deps = sorted(components, key=attrgetter('rank', 'name'))
    if debug:
        print('\nDependencies:')
        for comp in deps:
            print comp
        print('-----------------------------------')
        print('\nFull dependence tree')
        print_tree(tree)
        print('-----------------------------------')
        unnecessary_dependencies(tree)
    return deps
コード例 #2
0
def currentDirectoryModule():
    c = component.Component(os.getcwd())
    if not c:
        logging.error(str(c.error))
        logging.error('The current directory does not contain a valid module.')
        return None
    return c
コード例 #3
0
ファイル: test_mortal.py プロジェクト: Alberdi/humants
 def setUp(self):
     self.e = entity.Entity()
     self.e.add_component(components.mortal.Mortal())
     c = component.Component()
     c.attributes = [("test", True)]
     c.handlers = [("handler", lambda e, p: e.add_attribute("handled"))]
     self.e.add_component(c)
コード例 #4
0
    def setFromDict(self, designObject, myShipDict):
        """setup this ship according to the design object and ship dictionary info given"""
        self.myDesign = designObject
        self.designID = designObject.id
        self.componentdata = designObject.componentdata
        self.weapondata = designObject.weapondata
        self.myShipHull = designObject.myShipHull
        designAttrDict = designObject.getMyInfoAsDict()
        self.currentISP = myShipDict['currentISP']

        for position, dQuad in myShipDict['quads'].iteritems():
            newQuad = quad.Quad(dQuad)
            newQuad.setMyParent(self)
            # weapons have to be created first
            for id, dWeap in dQuad['weapons'].iteritems():
                newWeap = weapon.Weapon(dWeap)
                newWeap.setMyQuad(newQuad)
            for id, dComp in dQuad['components'].iteritems():
                newComp = component.Component(dComp)
                newComp.setMyQuad(newQuad)
            newQuad.setMyStatus()
            self.quads[newQuad.position] = newQuad
            newQuad.resetDefences()
            newQuad.reloadAmmo()

        self.setMyStatus()
        self.name = designObject.name + '-' + self.id
        self.randomizeJunkTrail()
コード例 #5
0
def searchPathsForComponent(name, version_required, search_paths):
    for path in search_paths:
        component_path = os.path.join(path, name)
        logger.debug("check path %s for %s" % (component_path, name))
        local_component = component.Component(
            component_path,
            installed_previously=True,
            installed_linked=fsutils.isLink(component_path),
            latest_suitable_version=None)
        if local_component:
            return local_component
    return None
コード例 #6
0
ファイル: validate.py プロジェクト: ntoll/yotta
def currentDirectoryModule():
    try:
        c = component.Component(os.getcwd())
    except pack.InvalidDescription as e:
        logging.error(e)
        return None

    if not c:
        logging.error(str(c.error))
        logging.error('The current directory does not contain a valid module.')
        return None
    return c
コード例 #7
0
 def __call__(self, word_emb):
     num_words = self._num_words
     num_samples = self._num_samples
     counts = self._counts
     prefix = self._name + '/' if self._name else ''
     with tf.device('/cpu:0'):
         with tf.variable_scope(prefix + 'context'):
             context_word = tf.placeholder(dtype=tf.int64,
                                           shape=[None],
                                           name='word')
             context_word_ = tf.reshape(context_word, [-1, 1], name='word_')
             loss = skipgram_nce_loss(num_words, num_samples, counts,
                                      word_emb, context_word_)
             word2id_extractor = Word2Id(self._words, prefix + 'context/')
             return component.Component([context_word],
                                        loss,
                                        feature_extractor=word2id_extractor)
コード例 #8
0
ファイル: script.py プロジェクト: dhh1128/sandman
 def build(self, sb, options, targets):
     '''
     Make all enumerated targets.
     '''
     err = 0
     if targets == ['config']:
         self.config(sb, options)
     else:
         if options.timeout is None:
             options.timeout = 120
         cc = sb.get_cached_components()
         if not cc:
             print(
                 '%s/dependencies.txt not found; do you need to do a "bzr sb update"?'
                 % sb.get_name())
             print('Proceeding with implied component list.')
             cc = sb.get_on_disk_components()
             br = sb.get_branch()
             cc = [
                 component.Component(c, br, None,
                                     component.CODE_ASPECT_NAME)
                 for c in sb.get_on_disk_components()
                 if sb.get_component_reused_aspect(c) ==
                 component.CODE_ASPECT_NAME
             ]
         for c in cc:
             if c.reused_aspect == 'code':
                 makefile = sb.get_component_path(
                     c.name,
                     component.CODE_ASPECT_NAME) + self.get_build_file()
                 if os.path.isfile(makefile):
                     cmd = 'python %s' % self.get_build_file()
                     if targets:
                         cmd += ' ' + ' '.join(targets)
                     print('Building %s...' % c.name)
                     err2, stdout = run_make_command(
                         cmd,
                         timeout=options.timeout,
                         cwd=os.path.dirname(makefile))
                     if err2:
                         err = 1
                         print('... FAILED')
                     else:
                         print('... OK')
     return err
コード例 #9
0
    def __init__(self, specs, bias=0.0):
        """Initializes a decomposition object. Demeter: save copies of 
           component elements for wrapper-level querying."""
        self._components = []

        self.bias = bias
        self.specs = specs
        for spec in specs:
            # For historical reasons, given as: (amp, decay, freq, phase)
            amp, decay, freq, ph = spec
            self._components.append(c.Component(amp, decay, freq, phase=ph))

        self.freqs = [comp.freq for comp in self._components]
        self.amps = [comp.amp for comp in self._components]
        self.decays = [comp.decay for comp in self._components]
        self.periods = [comp.period for comp in self._components]
        self.phases = [comp.phase for comp in self._components]
        self.offsets = [comp.offset for comp in self._components]
コード例 #10
0
def _satisfyVersionByInstallingVersion(name, version_required,
                                       working_directory, version):
    ''' installs and returns a Component for the specified version requirement into
        'working_directory' using the provided remote version object.
        This function is not normally called via `satisfyVersionByInstalling',
        which looks up a suitable remote version object.
    '''
    assert (version)
    logger.info('download ' + name)
    version.unpackInto(working_directory)
    r = component.Component(working_directory)
    if not r:
        raise Exception('Dependency "%s":"%s" is not a valid component.' %
                        (name, version_required))
    if name != r.getName():
        raise Exception(
            'Component %s (specification %s) has incorrect name %s' %
            (name, version_required, r.getName()))
    return r
コード例 #11
0
ファイル: tty.py プロジェクト: dhtdht020/OpenPython
def keyboard():
    if window.keyboard:
        return window.keyboard

    system_keyboard = component.get_primary(
        "keyboard").address if component.is_available("keyboard") else None
    screen = window.screen

    if not screen:
        return "no_system_keyboard"

    if component.is_available("screen") and component.get_primary(
            "screen").address == screen:
        window.keyboard = system_keyboard
    else:
        window.keyboard = component.Component(
            screen).getKeyboards() or system_keyboard

    return window.keyboard
コード例 #12
0
ファイル: validate.py プロジェクト: ntoll/yotta
def currentDirectoryModuleOrTarget():
    wd = os.getcwd()
    errors = []
    p = None
    try:
        p = component.Component(wd)
    except pack.InvalidDescription as e:
        errors.append(e)
    if not p:
        try:
            p = target.Target(wd)
        except pack.InvalidDescription as e:
            errors.append(e)
    if not p:
        for e in errors:
            logging.debug(e)
        logging.error(
            'The current directory does not contain a valid module or target.')
        return None
    return p
コード例 #13
0
ファイル: ship.py プロジェクト: colshag/ANW
    def setMyDesign(self, designObject):
        """Copy the Ship Design Attributes, Quads to ship"""
        self.myDesign = designObject
        self.designID = designObject.id
        self.componentdata = designObject.componentdata
        self.weapondata = designObject.weapondata
        self.myShipHull = designObject.myShipHull
        designAttrDict = designObject.getMyInfoAsDict()
        self.currentISP = self.myShipHull.maxISP
        self.currentPower = designAttrDict['maxPower']
        self.maxBattery = designAttrDict['maxBattery']
        self.thrust = designAttrDict['thrust']
        self.rotation = designAttrDict['rotation']
        self.radar = designAttrDict['radar']
        self.jamming = designAttrDict['jamming']
        self.repair = designAttrDict['repair']
        self.maxAssault = designAttrDict['maxAssault']
        self.mass = self.myShipHull.mass

        for position, dQuad in designObject.quads.iteritems():
            newQuad = quad.Quad(dQuad.getMyInfoAsDict())
            newQuad.setMyParent(self)
            # weapons have to be created first
            for id, weap in dQuad.weapons.iteritems():
                newWeap = weapon.Weapon(weap.getMyInfoAsDict())
                newWeap.setMyQuad(newQuad)
            for id, comp in dQuad.components.iteritems():
                newComp = component.Component(comp.getMyInfoAsDict())
                newComp.setMyQuad(newQuad)
            newQuad.setMyStatus()
            self.quads[newQuad.position] = newQuad
            newQuad.resetDefences()
            newQuad.reloadAmmo()

        self.name = designObject.name + '-' + self.id
        self.setMyStrength()
        if 'AS' in self.myShipHull.abr:
            self.isAssault = 1
        else:
            self.isAssault = 0
コード例 #14
0
ファイル: test_component.py プロジェクト: Alberdi/humants
 def setUp(self):
     self.e = entity.Entity()
     self.c = component.Component()
コード例 #15
0
 def add_component(self, path):
     comp = component.Component()
     #try:
     comp.read(path)
     self.components.append(comp)
コード例 #16
0
    def noise_removal(self):
        #        print("\n----------before noise_removal-----------")

        #        self.print_im()
        self.image_graph = graph.Image_graph(self.image)

        self.image_graph.search_connected_components()

        components = []

        #        print("")
        #        self.pr(im)
        for c in self.image_graph.connected_components:
            cm = component.Component(c)
            components.append(cm)
#            cm.delete(im)
#            self.pr(im)

        if len(components) <= 1:
            return

        sizes = []
        for i in components:
            sizes += [-max(i.width, i.height)]

        sizes.sort()

        min_letter_size = sizes[len(sizes) - 1]

        for i in range(1, len(sizes)):
            if (float(sizes[i - 1]) / float(sizes[i]) > 1.5):
                min_letter_size = sizes[i - 1]
                break

        min_letter_size = -min_letter_size
        #
        #        print("min_letter_size", min_letter_size)

        #        self.print_im()
        for c in components:
            #            print("delete")
            if (max(c.width, c.height) < min_letter_size):
                c.delete(self.image)
#                print("THERE")
#                for point in c.points:
#
#                    print(point)
#                    self.image[point[0]][point[1]] = BLACK
#                self.print_im()
#            self.print_im()

#        print("\n----------after noise_removal-----------")
#        self.print_im()

        self.image_graph = graph.Image_graph(self.image)
        self.image_graph.search_connected_components()

        components = []

        #        print("")
        #        self.pr(im)
        for c in self.image_graph.connected_components:
            cm = component.Component(c)
            components.append(cm)
#            cm.delete(im)
#            self.pr(im)

#        print("c count", len(components))

        if len(components) <= 1:
            return

        sizes = []
        for i in components:
            sizes += [-i.points_count]

        sizes.sort()

        min_letter_size = sizes[len(sizes) - 1]

        for i in range(1, len(sizes)):
            if (float(sizes[i - 1]) / float(sizes[i]) > 2):
                min_letter_size = sizes[i - 1]
                break

        min_letter_size = -min_letter_size
        #
        #        print("min_letter_size", min_letter_size)

        #        self.print_im()
        for c in components:
            #            print("delete")
            if (c.points_count < min_letter_size):
                #                print("THERE")
                for point in c.points:
                    #                    print(point)
                    self.image[point[0]][point[1]] = BLACK
コード例 #17
0
ファイル: test_entity.py プロジェクト: Alberdi/humants
 def setUp(self):
     self.e = entity.Entity()
     self.c = component.Component()
     self.c.got_added = lambda e: e.add_attribute("added")
     self.c.got_removed = lambda e: e.add_attribute("removed")
     self.c.update = lambda e, p: e.add_attribute("updated")
コード例 #18
0
ファイル: metadata.py プロジェクト: dhh1128/sandman
def _get_deps(working_repo,
              platform,
              top_component,
              code_root,
              read_deps,
              already_analyzed,
              use_master=False,
              check_vcs=True):
    if top_component.name == 'buildscripts':
        top_component.reused_aspect = component.CODE_ASPECT_NAME


##TODO julie why would we do this?
##    if top_component.reused_aspect == component.BUILT_ASPECT_NAME:
##        interesting_branches = [b for b in working_repo.branches if b[1] == top_component.name and b[2].startswith(component.BUILT_ASPECT_NAME) and b[0] == top_component.branch]
##        if not interesting_branches:
##            top_component.reused_aspect = component.CODE_ASPECT_NAME
    folder = ''
    if (not top_component.revision) and code_root:
        fldr = os.path.join(code_root, top_component.name)
        if os.path.isdir(fldr):
            if check_vcs and vcs.folder_is_tied_to_vcs(fldr):
                output = vcs.get_status(fldr,
                                        status_filter=lambda lbl: lbl ==
                                        'modified' or lbl == 'added')
                if output:
                    if 'modified' in output:
                        if METADATA_FILE in output['modified']:
                            folder = fldr
                    if 'added' in output:
                        if METADATA_FILE in output['added']:
                            folder = fldr
            else:
                folder = fldr
    if folder:
        if folder in already_analyzed:
            return top_component  #sections = already_analyzed[folder]
        else:
            print('\nLoading %s from %s.' % (METADATA_FILE, folder))
            x = get_section_info_from_disk(MISC_SECTION, folder)
            if 'terminal dependency' in x and top_component.reused_aspect.startswith(
                    component.BUILT_ASPECT_NAME):
                return top_component
            sections = get_section_info_from_disk(DEPENDENCIES_SECTION, folder)
            already_analyzed[folder] = sections
    elif check_vcs:
        key = '%s:%s' % (top_component.name, top_component.reused_aspect
                         )  #str(top_component)
        if key in already_analyzed:
            return top_component  #sections = already_analyzed[key]
        else:
            x = get_section_info_from_vcs(MISC_SECTION, top_component,
                                          working_repo, platform, use_master)
            if 'terminal dependency' in x and top_component.reused_aspect.startswith(
                    component.BUILT_ASPECT_NAME):
                return top_component
            sections = get_section_info_from_vcs(DEPENDENCIES_SECTION,
                                                 top_component, working_repo,
                                                 platform, use_master)
            already_analyzed[key] = sections
    else:
        return top_component

    compOldDeps = False
    for componentname, info in sections.iteritems():
        componentname = componentname.strip()
        aspect, revision, old = component.parse_component_info(info)
        if aspect == component.BUILT_ASPECT_NAME:
            aspect += "." + platform
        if old:
            compOldDeps = True
        componentname, ignored, branch, task = working_repo.normalize(
            componentname, aspect, top_component.branch)
        if revision:
            m = _TAG_PAT.match(revision)
            if not m:
                raise Exception(
                    '%s is not a valid tag for pinning dependencies.' %
                    revision)
        assert (aspect)
        top_component.dependencies.append(
            component.Component(componentname,
                                branch,
                                revision,
                                aspect,
                                parent=top_component))
    if compOldDeps:
        print('''Component %s/%s/%s has the old format for dependencies.
Please update dependencies in metadata.txt to match format found at:
https:// ... /working-with-code/concepts/dependencies''' %
              (top_component.name, top_component.reused_aspect,
               top_component.branch))  # TODO KIM refer to doc site
    top_component.rank += len(top_component.dependencies)
    for dep in top_component.dependencies:
        if top_component.reused_aspect.startswith(component.BUILT_ASPECT_NAME):
            dep.reused_aspect = top_component.reused_aspect
        # We are suspicious that this optimization isn't working
        if str(dep) not in read_deps or read_deps[str(dep)] != dep:
            read_deps[str(dep)] = dep
            dep = _get_deps(working_repo, platform, dep, code_root, read_deps,
                            already_analyzed, use_master, check_vcs)
        top_component.rank += dep.rank
    return top_component
コード例 #19
0
def read_xml(
    path='/Users/massimosferza/LRZ Sync+Share/TUM/TUM SoSe16/Courses/Software Lab/Git_repository/no-block-example.xml'
):
    """It creates a structure object for the OoD problem to solve, given a
proper .xml file"""

    # create a tree object, given the correct address of the .xml file
    tree = et.parse(path)

    # create a variable that contains the root
    root = tree.getroot()

    #############################################################
    # create a structure
    new_structure = structure.Structure()

    #############################################################
    # create all the loadpaths
    # loop over the element <level> </level> contained in root
    for level in root.iter('level'):

        # create a loadpath
        level_id = int(level.find('id').text)
        loadpath_obj = lp.Loadpath(level_id)

        #############################################################
        # add nodes to each loadpath
        for component in level.iter('component'):
            # for every component in the level, get x1
            x_position = float(component.find('x1').text)

            # check if the loadpath already contains a node corresponding to x1
            already_contained = False
            for node in loadpath_obj.node_list:
                if x_position == node.x_position:
                    already_contained = True
                    break
            if not already_contained:
                # if not add it
                loadpath_obj.node_list.append(nd.Node(x_position))

            # for every component, that is not a connection
            if not 'X' in component.find('name').text:
                # get also x2
                x_position = float(component.find('x2').text)

                # and again
                # check if the loadpath already contains a node corresponding to
                # x2
                already_contained = False
                for node in loadpath_obj.node_list:
                    if x_position == node.x_position:
                        already_contained = True
                        break
                if not already_contained:
                    # if not add it
                    loadpath_obj.node_list.append(nd.Node(x_position))

        #############################################################
        # add members to each loadpath
        for component in level.iter('component'):
            # for every component, that is not a connection
            if not 'X' in component.find('name').text:

                # get the previously created nodes
                x1 = float(component.find('x1').text)
                x2 = float(component.find('x2').text)
                for node in loadpath_obj.node_list:
                    if x1 == node.x_position:
                        node1 = node
                    if x2 == node.x_position:
                        node2 = node

                # create a member
                member_obj = c.Component(
                    component.find('name').text, node1, node2,
                    float(component.find('defoLength').text),
                    float(component.find('defoRatio').text))

                # add the member to the loadpath
                loadpath_obj.component_list.append(member_obj)

        # add the loadpath to the structure
        new_structure.path_list.append(loadpath_obj)


#############################################################
# neglect all the connectionpaths
#############################################################
    return new_structure
コード例 #20
0
#########################################################
# 														#	
# 	  This is main function for this application		#
# 														#
#########################################################

import component

node1 = component.Component("NODE1","sender")
node2 = component.Component("NODE2","receiver")

if __name__ == "__main__":
	print("Running heart of ROS ...")
コード例 #21
0
ファイル: scrp_parser.py プロジェクト: ysminnpu/cReComp
def parse_scrp(path, debug=False):
    parser = scrp_yacc.ParseScrp()
    parser.parse_scrp(path)

    component_list = parser.component

    for temp_component in parser.component_list:
        component_name = temp_component['component_name']
        component = cp.Component(component_name)

        for elem in temp_component['in_out_signals']:
            (signal_type, width, name) = elem
            if signal_type == "input":
                component.add_input(name, width)
            elif signal_type == "output":
                component.add_output(name, width)
            elif signal_type == "inout":
                component.add_inout(name, width)
            else:
                raise Exception("Definition error in_out_signals")

        for elem in temp_component['option_signals']:
            (signal_type, width, name) = elem
            if signal_type == "reg":
                component.add_reg(name, width)
            elif signal_type == "wire":
                component.add_wire(name, width)
            else:
                raise Exception("Definition error option_signals")

        for communication in temp_component['communication']:
            (dummy, com_type) = communication[0]
            if com_type == "xillybus":
                com_obj = com.Xillybus_fifo()
                for elem in communication:
                    (specifier, paramter) = elem
                    if specifier == "rcv_cycle":
                        com_obj.set_rcv_cycle(paramter)
                    elif specifier == "snd_cycle":
                        com_obj.set_snd_cycle(paramter)
                    elif specifier == "condition":
                        com_obj.set_condition(paramter)
                    elif specifier == "fifo_width":
                        com_obj.set_fifo_width(paramter)
                    elif specifier == "rcv":
                        com_obj.assign("rcv", paramter)
                    elif specifier == "snd":
                        com_obj.assign("snd", paramter)
            component.add_com(com_obj)

        for userlogic in temp_component['userlogic']:
            (dummy, userlogic_path) = userlogic[0]
            (dummy, uut) = userlogic[1]

            ul_in = ul.Info()
            ul_in.get_userlogicinfo(userlogic_path)

            ul_obj = ul.UserlogicBase(ul_in.name, uut)
            ul_obj.ports = ul_in.ports
            ul_obj.filepath = userlogic_path

            for elem in userlogic:
                (signame_u, signame_c) = elem
                if signame_u != "userlogic_path" and signame_u != "instance_name":
                    ul_obj.assign(signame_u, signame_c)
            component.add_ul(ul_obj)

        if temp_component['generate_ros_package']:
            component.ros_packaging()

        component.show_info()
        component.componentize()
コード例 #22
0
ファイル: metadata_test.py プロジェクト: dhh1128/sandman
    def test_dependencies(self):
        tmpdir = tempfile.mkdtemp()
        #print('running test in temporary repo %s' % tmpdir)
        cwd = os.getcwd()
        try:
            template1 = '[%s]' % metadata.DEPENDENCIES_SECTION
            template2 = template1 + '''
%s: code,%s.trunk.1.1 use: reusable
%s: code,%s.trunk.1.1 use: reusable
'''
            template3 = template1 + '''
%s: code,%s.trunk.2.1 use: reusable
%s: code,%s.trunk.1.1 use: reusable
'''
            files = {
                'a': template2 % ('b', 'b', 'c', 'c'),
                'b': template1,
                'c': template3 % ('b', 'b', 'd', 'd'),
                'd': template1
            }
            testRepos = ['a', 'b', 'c', 'd']
            for t in testRepos:
                repoPath = os.path.join(tmpdir, 'trunk', t)
                os.makedirs(os.path.join(tmpdir, 'trunk', t))
                branchPath = repoPath + '/code'
                #print('init %s' % branchPath)
                vcs.init(branchPath, False)
                filePath = branchPath + '/' + metadata.METADATA_FILE
                save(filePath, files[t])
                os.chdir(branchPath)
                #print('adding %s' % filePath)
                vcs.add(filePath)
                #print('checking in %s' % filePath)
                vcs.checkin(filePath, 'Test', True)
                vcs.tag('%s.trunk.1.1 use: reusable' % t)
                if t == 'b':
                    #subprocess.Popen(['bzr', 'tag', 'first'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
                    filePath = branchPath + '/dependencies2.txt'
                    save(filePath, files[t])
                    vcs.add(filePath)
                    vcs.checkin(filePath, 'Test', True)
                    vcs.tag('%s.trunk.2.1 use: reusable' % t)
                #subprocess.Popen(['bzr', 'tags'])
            working_repo = vcs.WorkingRepository()
            working_repo._init(tmpdir, tmpdir, tmpdir)
            prob = metadata.get_components_inv_dep_order(
                working_repo, 'win_x64', 'a', tmpdir, 'trunk', '')
            comp = [
                component.Component('b', 'trunk', 'b.trunk.1.1 use: reusable',
                                    'code'),
                component.Component('d', 'trunk', 'd.trunk.1.1 use: reusable',
                                    'code'),
                component.Component('c', 'trunk', 'c.trunk.1.1 use: reusable',
                                    'code'),
                component.Component('a', 'trunk', 'a.trunk.1.1 use: reusable',
                                    'code')
            ]
            if False:
                for c in comp:
                    print("comp = " + str(c))
                for c in prob:
                    print("prob = " + str(c))
            # prob will have buildscripts; comp doesn't
            prob = [p for p in prob if p.name != 'buildscripts']
            self.assertEquals(len(comp), len(prob))
            for i in range(len(comp)):
                self.assertEquals(comp[i].name, prob[i].name)
        finally:
            os.chdir(cwd)
            shutil.rmtree(tmpdir)
コード例 #23
0
def getComps(nodes):
    ""
    comps = []
    for i in nodes:
        comp = component.Component()
        keys = i.getElementsByTagName('data')
        cId = ''
        cName = ''
        cOwner = ''
        cUser = ''
        cLang = ''
        cUIcom = ''
        cSanit = ''
        cTransform = ''
        cTransfer = ''
        cTrust = ''
        cDBint = ''
        cTime = ''
        cMaxmin = ''
        cCalltpf = ''
        cSpoof = ''
        cTamper = ''
        cEncryp = ''
        cAttach = ''
        cUError = ''
        cCliSer = ''
        cWeb = ''
        cLogB = ''
        cPCWS = ''
        cAS = ''
        cIS = ''
        cNC = ''
        cPC = ''
        try:
            for j in keys:
                att = j.attributes["key"].value
                if att == "id":
                    cId = j.childNodes[0].data
                if att == "name":
                    cName = j.childNodes[0].data
                if att == "owner":
                    cOwner = j.childNodes[0].data
                if att == "user":
                    cUser = j.childNodes[0].data
                if att == "language":
                    cLang = j.childNodes[0].data
                if att == "userInterface":
                    cUIcom = j.childNodes[0].data
                if att == "sanitize":
                    cSanit = j.childNodes[0].data
                if att == "transformData":
                    cTransform = j.childNodes[0].data
                if att == "transferData":
                    cTransfer = j.childNodes[0].data
                if att == "trust":
                    cTrust = j.childNodes[0].data
                if att == "databaseInteraction":
                    cDBint = j.childNodes[0].data
                if att == "timeoutOperations":
                    cTime = j.childNodes[0].data
                if att == "maxMinOperations":
                    cMaxmin = j.childNodes[0].data
                if att == "remote3PartyCall":
                    cCalltpf = j.childNodes[0].data
                if att == "spoofing":
                    cSpoof = j.childNodes[0].data
                if att == "tampering":
                    cTamper = j.childNodes[0].data
                if att == "encryption":
                    cEncryp = j.childNodes[0].data
                if att == "attachment":
                    cAttach = j.childNodes[0].data
                if att == "errorHandling":
                    cUError = j.childNodes[0].data
                if att == "clientServer":
                    cCliSer = j.childNodes[0].data
                if att == "webService":
                    cWeb = j.childNodes[0].data
                if att == "logBackupCapability":
                    cLogB = j.childNodes[0].data
                if att == "attackSurface":
                    cAS = j.childNodes[0].data
                if att == "impactSurface":
                    cIS = j.childNodes[0].data
                if att == "antecesores":
                    cPC = j.childNodes[0].data
                if att == "predecesores":
                    cNC = j.childNodes[0].data
            comp.attrib(cId, cName, cOwner, cUser, cLang, cUIcom, cSanit,
                        cTransform, cTransfer, cTrust, cDBint, cTime, cMaxmin,
                        cCalltpf, cSpoof, cTamper, cEncryp, cAttach, cUError,
                        cCliSer, cWeb, cLogB, 0, cAS, cIS, cNC, cPC)
            comps.append(comp)
        except:
            print "Sorry:", sys.exc_info()[1]
            print traceback.print_exc(file=sys.stdout)

    return comps