コード例 #1
0
ファイル: annotate.py プロジェクト: ctb/figleaf
def build_python_coverage_info(coverage, exclude_patterns, files_list):
    keys = coverage.keys()
    
    line_info = {}
    for pyfile in filter_files(keys, exclude_patterns, files_list):
        try:
            fp = open(pyfile, 'rU')
            lines = figleaf.get_lines(fp)
        except KeyboardInterrupt:
            raise
        except IOError:
            logger.error('CANNOT OPEN: %s' % (pyfile,))
            continue
        except Exception, e:
            logger.error('ERROR: file %s, exception %s' % (pyfile, str(e)))
            continue

        # retrieve the coverage and merge into a realpath-based filename.
        covered = coverage.get(pyfile, set())
        realpath = os.path.realpath(pyfile)

        # be careful not to overwrite existing coverage for different
        # filenames that may have been canonicalized.
        (old_l, old_c) = line_info.get(realpath, (set(), set()))
        lines.update(old_l)
        covered.update(old_c)

        line_info[realpath] = (lines, covered)
コード例 #2
0
ファイル: selector.py プロジェクト: KeithLatteri/awips2
 def __init__(self):
   self.selectables = set()
   self.reading = set()
   self.writing = set()
   self.waiter = selectable_waiter()
   self.reading.add(self.waiter)
   self.stopped = False
   self.thread = None
コード例 #3
0
ファイル: selector.py プロジェクト: 571451370/devstack_mitaka
 def __init__(self):
     self.selectables = set()
     self.reading = set()
     self.writing = set()
     self.waiter = selectable_waiter()
     self.reading.add(self.waiter)
     self.stopped = False
     self.thread = None
コード例 #4
0
ファイル: git_repo.py プロジェクト: dannyfeng/gitGUI
    def __init__(self, cwd=None):
        """Reads git repository settings and sets several methods
        so that they refer to the git module.  This object
        encapsulates cola's interaction with git."""
        super(MainModel, self).__init__()

        # Initialize the git command object
        self.git = git.instance()

        self.head = 'HEAD'
        self.diff_text = ''
        self.mode = self.mode_none
        self.filename = None
        self.currentbranch = ''
        self.directory = ''
        self.project = ''
        self.remotes = []

        self.commitmsg = ''
        self.modified = []
        self.staged = []
        self.untracked = []
        self.unmerged = []
        self.upstream_changed = []
        self.submodules = set()

        self.local_branches = []
        self.remote_branches = []
        self.tags = []
        if cwd:
            self.set_worktree(cwd)
コード例 #5
0
ファイル: git_repo.py プロジェクト: dannyfeng/gitGUI
    def stage_paths(self, paths):
        """Stages add/removals to git."""
        if not paths:
            self.stage_all()
            return

        add = []
        remove = []

        for path in set(paths):
            if os.path.exists(core.encode(path)):
                add.append(path)
            else:
                remove.append(path)

        self.notify_observers(self.message_about_to_update)

        # `git add -u` doesn't work on untracked files
        if add:
            self._sliced_add(add)

        # If a path doesn't exist then that means it should be removed
        # from the index.   We use `git add -u` for that.
        if remove:
            while remove:
                self.git.add('--', u=True, with_stderr=True, *remove[:42])
                remove = remove[42:]

        self._update_files()
        self.notify_observers(self.message_updated)
コード例 #6
0
ファイル: internals.py プロジェクト: ctb/figleaf
 def update_coverage(self, coverage1, coverage2):
     for filename, lines in coverage2.items():
         #filename = os.path.realpath(os.path.abspath(filename))
         if filename in coverage1:
             coverage1[filename].update(lines)
         else:
             coverage1[filename] = set(lines)
コード例 #7
0
ファイル: git_repo.py プロジェクト: dannyfeng/gitGUI
 def _update_files(self, update_index=False):
     state = gitcmds.worktree_state_dict(head=self.head,
                                         update_index=update_index)
     self.staged = state.get('staged', [])
     self.modified = state.get('modified', [])
     self.unmerged = state.get('unmerged', [])
     self.untracked = state.get('untracked', [])
     self.submodules = state.get('submodules', set())
     self.upstream_changed = state.get('upstream_changed', [])
コード例 #8
0
ファイル: __init__.py プロジェクト: ctb/figleaf
def combine_coverage(d1, d2):
    """
    Given two coverage dictionaries, combine the recorded coverage
    and return a new dictionary.
    """
    keys = set(d1.keys())
    keys.update(set(d2.keys()))

    new_d = {}
    for k in keys:
        v = d1.get(k, set())
        v2 = d2.get(k, set())

        s = set(v)
        s.update(v2)
        new_d[k] = s

    return new_d
コード例 #9
0
ファイル: internals.py プロジェクト: ctb/figleaf
 def gather_sections(self, file):
     """
     Return a dictionary of sets containing section coverage information for
     a specific file.  Dict keys are sections, and the dict values are
     sets containing (integer) line numbers.
     """
     sections = {}
     for section_name, c in self.sections.items():
         s = set()
         for filename in c.keys():
             if filename == file:
                 lines = c[filename]
                 s.update(lines)
         sections[section_name] = s
     return sections
コード例 #10
0
ファイル: internals.py プロジェクト: ctb/figleaf
 def t(self, f, e, a):
     """
     local trace function.
     """
     if e is 'line':
         filename = f.f_code.co_filename
         if filename is self.latest:
             self.latest_lines.add(f.f_lineno)
         else:
             if filename in self.c:
                 latest_lines = self.c[filename]
                 latest_lines.add(f.f_lineno)
             else:
                 latest_lines = set([f.f_lineno])
                 self.c[filename] = latest_lines
             self.latest = filename
             self.latest_lines = latest_lines
     return self.t
コード例 #11
0
ファイル: internals.py プロジェクト: ctb/figleaf
def get_interesting_lines(code):
    """
    Count 'interesting' lines of Python in a code object, where
    'interesting' is defined as 'lines that could possibly be
    executed'.

    This is done by dissassembling the code objecte and returning
    line numbers.
    """

    # clean up weird end-of-file issues

    lines = set([ l for (o, l) in findlinestarts(code) ])
    for const in code.co_consts:
        if type(const) == types.CodeType:
            lines.update(get_interesting_lines(const))

    return lines
コード例 #12
0
ファイル: util.py プロジェクト: jaggyluis/decodes
determining the type of an object.
"""
import base64
import operator
import time
import types

import tags
from compat import set
from compat import unicode
from compat import long
from compat import PY3


SEQUENCES = (list, set, tuple)
SEQUENCES_SET = set(SEQUENCES)
PRIMITIVES = set((str, unicode, bool, float, int, long))


def is_type(obj):
    """Returns True is obj is a reference to a type.

    >>> is_type(1)
    False

    >>> is_type(object)
    True

    >>> class Klass: pass
    >>> is_type(Klass)
    True
コード例 #13
0
ファイル: notification.py プロジェクト: dannyfeng/gitGUI
 def connect(self, signal, callback):
     subscribers = self.channels.setdefault(signal, set())
     subscribers.add(callback)
コード例 #14
0
"""The jsonpickle.tags module provides the custom tags
used for pickling and unpickling Python objects.

These tags are keys into the flattened dictionaries
created by the Pickler class.  The Unpickler uses
these custom key names to identify dictionaries
that need to be specially handled.
"""
from compat import set

ID = 'py_id'
OBJECT = 'py_object'
TYPE = 'py_type'
REPR = 'py_repr'
REF = 'py_ref'
TUPLE = 'py_tuple'
SET = 'py_set'
SEQ = 'py_seq'
STATE = 'py_state'
JSON_KEY = 'json://'

# All reserved tag names
RESERVED = set([OBJECT, TYPE, REPR, REF, TUPLE, SET, SEQ, STATE])
コード例 #15
0
ファイル: unpickler.py プロジェクト: jaggyluis/decodes
 def _restore_set(self, obj):
     return set([self._restore(v) for v in obj[tags.SET]])
コード例 #16
0
ファイル: observable.py プロジェクト: dannyfeng/gitGUI
 def add_observer(self, message, observer):
     """Add an observer for a specific message."""
     observers = self.observers.setdefault(message, set())
     observers.add(observer)
コード例 #17
0
ファイル: unpickler.py プロジェクト: RafaelMri/gh-decodes
 def _restore_set(self, obj):
     return set([self._restore(v) for v in obj[tags.SET]])