예제 #1
0
파일: pathlib.py 프로젝트: tibaldo/gammapy
 def samefile(self, other_path):
     """Return whether `other_file` is the same or not as this file.
     (as returned by os.path.samefile(file, other_file)).
     """
     if hasattr(os.path, "samestat"):
         st = self.stat()
         try:
             other_st = other_path.stat()
         except AttributeError:
             other_st = os.stat(other_path)
         return os.path.samestat(st, other_st)
     else:
         filename1 = six.text_type(self)
         filename2 = six.text_type(other_path)
         st1 = _win32_get_unique_path_id(filename1)
         st2 = _win32_get_unique_path_id(filename2)
         return st1 == st2
예제 #2
0
 def samefile(self, other_path):
     """Return whether `other_file` is the same or not as this file.
     (as returned by os.path.samefile(file, other_file)).
     """
     if hasattr(os.path, "samestat"):
         st = self.stat()
         try:
             other_st = other_path.stat()
         except AttributeError:
             other_st = os.stat(other_path)
         return os.path.samestat(st, other_st)
     else:
         filename1 = six.text_type(self)
         filename2 = six.text_type(other_path)
         st1 = _win32_get_unique_path_id(filename1)
         st2 = _win32_get_unique_path_id(filename2)
         return st1 == st2
예제 #3
0
 def recurse(tree, path=[]):
     if isinstance(tree, dict):
         for key, val in six.iteritems(tree):
             for x in recurse(val, path + [key]):
                 yield x
     elif isinstance(tree, (list, tuple)):
         for i, val in enumerate(tree):
             for x in recurse(val, path + [i]):
                 yield x
     elif tree is not None:
         yield (str('.'.join(six.text_type(x) for x in path)), tree)
예제 #4
0
파일: model_base.py 프로젝트: nden/jwst
 def recurse(tree, path=[]):
     if isinstance(tree, dict):
         for key, val in six.iteritems(tree):
             for x in recurse(val, path + [key]):
                 yield x
     elif isinstance(tree, (list, tuple)):
         for i, val in enumerate(tree):
             for x in recurse(val, path + [i]):
                 yield x
     elif tree is not None:
         yield ('.'.join(six.text_type(x) for x in path), tree)
예제 #5
0
파일: fits_support.py 프로젝트: sosey/jwst
def _get_indexed_keyword(keyword, i):
    for (sub, max, r) in _keyword_indices:
        if sub in keyword:
            if i >= max:
                raise ValueError(
                    "Too many entries for given keyword '{0}'".format(keyword))
            if r is None:
                val = six.text_type(i)
            else:
                val = r[i]
            keyword = keyword.replace(sub, val)

    return keyword
예제 #6
0
    def uri(self):
        """
        The URI pointing to the result
        """

        # TODO: use a async job base class instead of hasattr for inspection
        if hasattr(self._content, "result_uri"):
            self._content.raise_if_error()
            uri = self._content.result_uri
        else:
            uri = six.text_type(self._content)

        return uri
예제 #7
0
def _get_indexed_keyword(keyword, i):
    for (sub, max, r) in _keyword_indices:
        if sub in keyword:
            if i >= max:
                raise ValueError(
                    "Too many entries for given keyword '{0}'".format(keyword))
            if r is None:
                val = six.text_type(i)
            else:
                val = r[i]
            keyword = keyword.replace(sub, val)

    return keyword
예제 #8
0
파일: main.py 프로젝트: aarchiba/pyasdf
def main_from_args(args):
    parser, subparsers = make_argparser()

    args = parser.parse_args(args)

    # Only needed for Python 3, apparently, but can't hurt
    if not hasattr(args, 'func'):
        parser.print_help()
        return 2

    try:
        result = args.func(args)
    except RuntimeError as e:
        log.error(six.text_type(e))
        return 1
    except IOError as e:
        log.error(six.text_type(e))
        return e.errno

    if result is None:
        result = 0

    return result
예제 #9
0
def main_from_args(args):
    parser, subparsers = make_argparser()

    args = parser.parse_args(args)

    # Only needed for Python 3, apparently, but can't hurt
    if not hasattr(args, 'func'):
        parser.print_help()
        return 2

    try:
        result = args.func(args)
    except RuntimeError as e:
        log.error(six.text_type(e))
        return 1
    except IOError as e:
        log.error(six.text_type(e))
        return e.errno

    if result is None:
        result = 0

    return result
예제 #10
0
파일: main.py 프로젝트: ejeschke/pyasdf
def main_from_args(args):
    parser, subparsers = make_argparser()

    args = parser.parse_args(args)

    if not hasattr(args, 'func'):
        parser.print_help()
        return 1

    try:
        result = args.func(args)
    except RuntimeError as e:
        log.error(six.text_type(e))
        return 1

    sys.stdout.write('\n')

    if result is None:
        result = 0

    return result
예제 #11
0
    def describe(self, width=None):
        """
        Print a summary description of this service.

        This includes the interface capabilities, and the content description
        if it doesn't contains multiple data collections (in other words, it is
        not a TAP service).
        """
        if len(self.tables) == 1:
            description = next(self.tables.values()).description

            if width:
                description = para_format_desc(description, width)

            print(description)
            print()

        capabilities = filter(
            lambda x: not six.text_type(x.standardid).startswith(
                'ivo://ivoa.net/std/VOSI'), self.capabilities)

        for cap in capabilities:
            cap.describe()
            print()
예제 #12
0
파일: fits_support.py 프로젝트: sosey/jwst
 def convert_datetimes(node, json_id):
     if isinstance(node, datetime.datetime):
         node = time.Time(node)
     if isinstance(node, time.Time):
         node = six.text_type(time.Time(node, format='iso'))
     return node
예제 #13
0
파일: complex.py 프로젝트: ejeschke/pyasdf
 def to_tree(cls, node, ctx):
     return six.text_type(node)
예제 #14
0
 def convert_datetimes(node, json_id):
     if isinstance(node, datetime.datetime):
         node = time.Time(node)
     if isinstance(node, time.Time):
         node = six.text_type(time.Time(node, format='iso'))
     return node
예제 #15
0
파일: complex.py 프로젝트: nden/pyasdf
 def to_tree(cls, node, ctx):
     return six.text_type(node)