当前位置: 首页>>代码示例>>Python>>正文


Python logr.Logr类代码示例

本文整理汇总了Python中logr.Logr的典型用法代码示例。如果您正苦于以下问题:Python Logr类的具体用法?Python Logr怎么用?Python Logr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_usage

    def get_usage(self, month=None, year=None):
        if not month:
            month = datetime.date.today().month
        if not year:
            year = datetime.date.today().year

        # Check if we have already cached the result
        obj_hash = self.cache_hash(month, year)
        if self.cache_valid(obj_hash):
            return self.cache[obj_hash]['result']

        # Ensure we are logged in
        if not self.conn:
            self.login()

        result = None

        try:
            Logr.info("Retrieving latest data usage details")
            usage = self.conn.get_usage(month, year)

            result = {
                'total': usage.total,
                'days': usage.days
            }
        except CompassConnectionException:
            pass

        # Cache the result
        self.cache[obj_hash] = {
            'result': result,
            'date': datetime.datetime.utcnow()
        }

        return result
开发者ID:fuzeman,项目名称:SmartUsageMeter,代码行数:35,代码来源:compass.py

示例2: parse

    def parse(self, titles):
        root = []
        tails = []

        for title in titles:
            Logr.debug(title)

            cur = None
            words = title.split(' ')

            for wx in xrange(len(words)):
                word = strip(words[wx])

                if cur is None:
                    cur = find_node(root, word)

                    if cur is None:
                        cur = DNode(word, None, num_children=len(words) - wx, original_value=title)
                        root.append(cur)
                else:
                    parent = cur
                    parent.weight += 1

                    cur = find_node(parent.right, word)

                    if cur is None:
                        Logr.debug("%s %d", word, len(words) - wx)
                        cur = DNode(word, parent, num_children=len(words) - wx)
                        sorted_append(parent.right, cur, lambda a: a.num_children < cur.num_children)
                    else:
                        cur.weight += 1

            tails.append(cur)

        return root, tails
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:35,代码来源:merge.py

示例3: test_merge_is_order_independent

    def test_merge_is_order_independent(self):
        root_one = [
            self._create_chain(['avatar', 'the', 'legend', 'of', 'korra']),
            self._create_chain(['la', 'leggenda', 'di', 'korra']),
            self._create_chain(['the', 'last', 'airbender', 'the', 'legend', 'of', 'korra'])
        ]

        self._create_chain(['legend', 'of', 'korra'], root_one[-1])

        root_one.append(self._create_chain(['legend', 'of', 'korra']))

        result_one = self.merge.merge(root_one)

        Logr.debug("-----------------------------------------------------------------")

        root_two = [
            self._create_chain(['the', 'legend', 'of', 'korra']),
        ]

        self._create_chain(['last', 'airbender', 'the', 'legend', 'of', 'korra'], root_two[-1])

        root_two += [
            self._create_chain(['legend', 'of', 'korra']),
            self._create_chain(['la', 'leggenda', 'di', 'korra']),
            self._create_chain(['avatar', 'the', 'legend', 'of', 'korra'])
        ]

        result_two = self.merge.merge(root_two)

        Logr.debug("=================================================================")

        assert itemsMatch(
            self._get_chain_values(result_one),
            self._get_chain_values(result_two)
        )
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:35,代码来源:test_transformers.py

示例4: parse_closure

    def parse_closure(self, parent_head, subject):
        parent_node = parent_head[0] if type(parent_head) is list else parent_head

        nodes, match = self.match(parent_head, parent_node, subject)

        # Capturing broke on constraint, return now
        if not match:
            return nodes

        Logr.debug('created closure node with subject.value: "%s"' % subject.value)

        result = [CaperClosureNode(
            subject,
            parent_head,
            match
        )]

        # Branch if the match was indefinite (weight below 1.0)
        if match.result and match.weight < 1.0:
            if match.num_fragments == 1:
                result.append(CaperClosureNode(subject, parent_head))
            else:
                nodes.append(CaperClosureNode(subject, parent_head))

        nodes.append(result[0] if len(result) == 1 else result)

        return nodes
开发者ID:Danik1601,项目名称:Plex-Trakt-Scrobbler,代码行数:27,代码来源:group.py

示例5: calculate_sim_links

def calculate_sim_links(for_node, other_nodes):
    for node in other_nodes:
        if node in for_node.links:
            continue

        Logr.debug('calculating similarity between "%s" and "%s"', for_node.value, node.value)

        # Get similarity
        similarity_matcher = create_matcher(for_node.value, node.value)
        similarity = similarity_matcher.quick_ratio()

        # Get for_node -> node opcodes
        a_opcodes_matcher = create_matcher(for_node.value, node.value, swap_longest = False)
        a_opcodes = a_opcodes_matcher.get_opcodes()
        a_stats = get_opcode_stats(for_node, node, a_opcodes)

        Logr.debug('-' * 100)

        # Get node -> for_node opcodes
        b_opcodes_matcher = create_matcher(node.value, for_node.value, swap_longest = False)
        b_opcodes = b_opcodes_matcher.get_opcodes()
        b_stats = get_opcode_stats(for_node, node, b_opcodes)

        for_node.links[node] = SimLink(similarity, a_opcodes, a_stats)
        node.links[for_node] = SimLink(similarity, b_opcodes, b_stats)
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:25,代码来源:slice.py

示例6: _merge

    def _merge(self, nodes, depth = 0):
        Logr.debug(str('\t' * depth) + str(nodes))

        if not len(nodes):
            return []

        top = nodes[0]

        # Merge into top
        for x in range(len(nodes)):
            # Merge extra results into top
            if x > 0:
                top.value = None
                top.weight += nodes[x].weight
                self.destroy_nodes_right(top.right)

                if len(nodes[x].right):
                    top.join_right(nodes[x].right)

                    Logr.debug("= %s joined %s", nodes[x], top)

                nodes[x].dead = True

        nodes = [n for n in nodes if not n.dead]

        # Traverse further
        for node in nodes:
            if len(node.right):
                node.right = self._merge(node.right, depth + 1)

        return nodes
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:31,代码来源:merge.py

示例7: merge

    def merge(self, root):
        for x in range(len(root)):
            Logr.debug(root[x])
            root[x].right = self._merge(root[x].right)
            Logr.debug('=================================================================')

        return root
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:7,代码来源:merge.py

示例8: print_tree

def print_tree(node, depth = 0):
    Logr.debug(str('\t' * depth) + str(node))

    if len(node.right):
        for child in node.right:
            print_tree(child, depth + 1)
    else:
        Logr.debug(node.full_value()[1])
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:8,代码来源:merge.py

示例9: load

    def load(self):
        parser = ConfigParser.ConfigParser()
        parser.read(os.path.join(self.base_dir, 'data.cfg'))

        for module_name, spec in self.module_loader.modules.items():
            if parser.has_section(module_name):
                self.load_module(parser, module_name, spec)
            else:
                Logr.debug("no section named '%s'" % module_name)
开发者ID:fuzeman,项目名称:SmartUsageMeter,代码行数:9,代码来源:config_loader.py

示例10: parse_subject

    def parse_subject(self, parent_head, subject):
        Logr.debug("parse_subject (%s) subject: %s", self.step_source, repr(subject))

        if type(subject) is CaperClosure:
            return self.parse_closure(parent_head, subject)

        if type(subject) is CaperFragment:
            return self.parse_fragment(parent_head, subject)

        raise ValueError('Unknown subject (%s)', subject)
开发者ID:Danik1601,项目名称:Plex-Trakt-Scrobbler,代码行数:10,代码来源:group.py

示例11: process

    def process(self, matches):
        matches = [match.groupdict() for match in matches]

        if self.transform:
            try:
                return self.transform(matches)
            except Exception as ex:
                Logr.warn('Exception raised while transforming matches: %s', ex)

        return matches
开发者ID:Danik1601,项目名称:Plex-Trakt-Scrobbler,代码行数:10,代码来源:objects.py

示例12: fragment_match

    def fragment_match(self, fragment, group_name=None):
        """Follow a fragment chain to try find a match

        :type fragment: caper.objects.CaperFragment
        :type group_name: str or None

        :return: The weight of the match found between 0.0 and 1.0,
                  where 1.0 means perfect match and 0.0 means no match
        :rtype: (float, dict, int)
        """

        group_name, weight_groups = self.find_group(group_name)

        for weight, patterns in weight_groups:
            for pattern in patterns:
                success = True
                result = {}

                num_matched = 0

                fragment_iterator = fragment.take_right(
                    return_type='value',
                    include_separators=pattern.include_separators,
                    include_source=True
                )

                for subject, fragment_pattern in itertools.izip_longest(fragment_iterator, pattern):
                    # No patterns left to match
                    if not fragment_pattern:
                        break

                    # No fragments left to match against pattern
                    if not subject:
                        success = False
                        break

                    value, source = subject

                    matches = pattern.execute(fragment_pattern, value)

                    if matches:
                        for match in pattern.process(matches):
                            update_dict(result, match)
                    else:
                        success = False
                        break

                    if source == 'subject':
                        num_matched += 1

                if success:
                    Logr.debug('Found match with weight %s using regex pattern "%s"' % (weight, [sre.pattern for sre in pattern.patterns]))
                    return float(weight), result, num_matched

        return 0.0, None, 1
开发者ID:Danik1601,项目名称:Plex-Trakt-Scrobbler,代码行数:55,代码来源:matcher.py

示例13: print_link_tree

def print_link_tree(nodes):
    for node in nodes:
        Logr.debug(node.value)
        Logr.debug('\tnum_merges: %s', node.num_merges)

        if len(node.links):
            Logr.debug('\t========== LINKS ==========')
            for link_node, link in node.links.items():
                Logr.debug('\t%0.2f -- %s', link.similarity, link_node.value)

            Logr.debug('\t---------------------------')
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:11,代码来源:slice.py

示例14: kill_nodes_above

def kill_nodes_above(nodes, above_sim):
    killed_nodes = []

    for node in nodes:
        if node.dead:
            continue

        Logr.debug(node.value)

        for link_node, link in node.links.items():
            if link_node.dead:
                continue

            Logr.debug('\t%0.2f -- %s', link.similarity, link_node.value)

            if link.similarity >= above_sim:
                if len(link_node.value) > len(node.value):
                    Logr.debug('\t\tvery similar, killed this node')
                    link_node.dead = True
                    node.num_merges += 1
                    killed_nodes.append(link_node)
                else:
                    Logr.debug('\t\tvery similar, killed owner')
                    node.dead = True
                    link_node.num_merges += 1
                    killed_nodes.append(node)

    kill_nodes(nodes, killed_nodes)
开发者ID:fuzeman,项目名称:QueryCondenser,代码行数:28,代码来源:slice.py

示例15: parse

    def parse(self, name, parser='scene'):
        closures = self._closure_split(name)
        closures = self._fragment_split(closures)

        # Print closures
        for closure in closures:
            Logr.debug("closure [%s]", closure.value)

            for fragment in closure.fragments:
                Logr.debug("\tfragment [%s]", fragment.value)

        if parser not in self.parsers:
            raise ValueError("Unknown parser")

        # TODO autodetect the parser type
        return self.parsers[parser](self.debug).run(closures)
开发者ID:ANTH040,项目名称:CouchPotatoServer,代码行数:16,代码来源:__init__.py


注:本文中的logr.Logr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。