示例#1
0
 def _open(self, path, section, mode='r'):
     if mode not in ['r', 'rb']:
         raise ValueError("invalid mode: " + repr(mode))
     path = path_in_section(path, section)
     if not path.startswith('/'):
         path = section + '/' + path
     return self.paper.open_internal_file(path, mode, 'utf8', None)
示例#2
0
def _open(filename, mode='r'):
    from activepapers.utility import path_in_section
    section = '/data'
    path = path_in_section(path, section)
    if not path.startswith('/'):
        path = section + '/' + path
    assert mode == 'r'
    return _paper.open_internal_file(path, 'r', None)
示例#3
0
def _open(filename, mode='r'):
    from activepapers.utility import path_in_section
    section = '/data'
    path = path_in_section(path, section)
    if not path.startswith('/'):
        path = section + '/' + path
    assert mode == 'r'
    return _paper.open_internal_file(path, 'r', None)
示例#4
0
 def _open_file(self, path, mode, encoding, section):
     if path.startswith(os.path.expanduser('~')):
         # Catch obvious attempts to access real files
         # rather than internal ones.
         raise IOError((13, "Permission denied: '%s'" % path))
     path = path_in_section(path, section)
     if not path.startswith('/'):
         path = section + '/' + path
     f = self.paper.open_internal_file(path, mode, encoding, self)
     f._set_attribute_callback(self.dependency_attributes)
     if mode[0] == 'r':
         self.add_dependency(f._ds.name)
     return f