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)
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)
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