rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
moveDir = moveDirectory() | moveDir = MoveDirectory() | def handleStartMoveDirectory(wfile, request, session): productionId=int(request["production_id"]) production=indexer.getProduction(productionId) sourceDirectory= str(request["source_directory"]) targetDirectory= str(request["target_directory"]) targetAbsoluteDirectory = os.path.join(production[indexer.INDEX_PRODUCTION_... |
if stat.entry is None and path.isfile(stat.path): temp[stat.path] = [None,None,str(stat.text_status)] | if stat.entry is None: if path.isfile(stat.path): temp[stat.path] = [None,None,str(stat.text_status)] | def handleGetProductionView(wfile, request, session): """Service to retrieve all production level information being: production files of the production scenes of the production missing links of the production """ production = indexer.getActiveProduction() result = [] if production is not None: productionId=production[0... |
return (SVNURLSAME); | return (SVNURLSAME, ""); | def testWorkingFolder(location, url): client = pysvn.Client() try: if path.isdir(location): locationUrl = client.info(location).url; if url==locationUrl: return (SVNURLSAME); else: return (SVNURLDIFF, locationurl); elif path.exists(location): return (SVNWORKINGFOLDERISFILE); else: return (SVNNOWORKINGFOLDER); except py... |
return (SVNWORKINGFOLDERISFILE); | return (SVNWORKINGFOLDERISFILE, ""); | def testWorkingFolder(location, url): client = pysvn.Client() try: if path.isdir(location): locationUrl = client.info(location).url; if url==locationUrl: return (SVNURLSAME); else: return (SVNURLDIFF, locationurl); elif path.exists(location): return (SVNWORKINGFOLDERISFILE); else: return (SVNNOWORKINGFOLDER); except py... |
return (SVNNOWORKINGFOLDER); | return (SVNNOWORKINGFOLDER, ""); | def testWorkingFolder(location, url): client = pysvn.Client() try: if path.isdir(location): locationUrl = client.info(location).url; if url==locationUrl: return (SVNURLSAME); else: return (SVNURLDIFF, locationurl); elif path.exists(location): return (SVNWORKINGFOLDERISFILE); else: return (SVNNOWORKINGFOLDER); except py... |
return (SVNNOBINDING); | return (SVNNOBINDING, ""); | def testWorkingFolder(location, url): client = pysvn.Client() try: if path.isdir(location): locationUrl = client.info(location).url; if url==locationUrl: return (SVNURLSAME); else: return (SVNURLDIFF, locationurl); elif path.exists(location): return (SVNWORKINGFOLDERISFILE); else: return (SVNNOWORKINGFOLDER); except py... |
location = os.path.join(production_path, rel_file_path) | location = path.join(production_path, rel_file_path) | def handleSvnAdd(wfile, request, session): file_id = request["file_id"] addAll = request["add_all"] result = indexer.getFile(file_id) production_id = result[1] file_name = result[2] rel_file_path = result[3] production_result = indexer.getProduction(production_id) production_path = production_result[2] location = os.pa... |
if lock=None: | if lock is None: | def operation(self, a, b): ... |
('linux' in sys.platform or 'bsd' in sys.platform or 'darwin' in sys.platform): | ('bsd' in sys.platform or 'darwin' in sys.platform): | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() |
common_install_requires.append('select_backport') | common_install_requires.append('select_backport >= 0.2') common_install_requires.append('argparse >= 1.1') | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() |
renamed_path = path_join(path_renamed, directory_path) | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) | |
renamed_path = path_join(path_renamed, filename) | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) | |
self._files_modified.add(path) | self._files_deleted.add(path) | def __init__(self, ref_dirsnap, dirsnap): self._files_deleted = set() self._files_modified = set() self._files_created = set() self._files_moved = dict() |
@arg('-a-', '--append-only', dest='append_only', default=False, help='if --append-to-file is not specified, produces output for appending instead of a complete tricks yaml file.') | @arg('-a', '--append-only', dest='append_only', default=False, help='if --append-to-file is not specified, produces output for appending instead of a complete tricks yaml file.') | def tricks_from(args): add_to_sys_path(path_split(args.python_path)) observers = [] for tricks_file in args.files: observer = Observer() if not path_exists(tricks_file): raise IOError("cannot find tricks file: %s" % tricks_file) config = load_config(tricks_file) if CONFIG_KEY_TRICKS not in config: raise KeyError("No... |
@arg('-r', '--recursive', dest='recursive', default=False, help='monitors the directories recursively') | @arg('-R', '--recursive', dest='recursive', default=False, help='monitors the directories recursively') | def tricks_generate_yaml(args): python_paths = path_split(args.python_path) add_to_sys_path(python_paths) output = StringIO() for trick_path in args.trick_paths: TrickClass = load_class(trick_path) output.write(TrickClass.generate_yaml()) content = output.getvalue() output.close() header = yaml.dump({CONFIG_KEY_PYTH... |
@arg('-r', '--recursive', dest='recursive', default=False, help='monitors the directories recursively') | @arg('-R', '--recursive', dest='recursive', default=False, help='monitors the directories recursively') | def log(args): from watchdog.tricks import LoggerTrick patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) event_handler = LoggerTrick(patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories) if args.debug_force_polling: from watchdog.observers.polling_... |
out_event_queue.put((event_handler, DirMovedEvent(src_dir_path, dest_dir_path))) | out_event_queue.put((self.event_handler, DirMovedEvent(src_dir_path, dest_dir_path))) | def queue_events(self, num_bytes, out_event_queue): with self._lock: # queue events last_renamed_from_filename = "" for action, filename in FILE_NOTIFY_INFORMATION(self.event_buffer.raw, num_bytes): filename = absolute_path(os.path.join(self.path, filename)) if action == FILE_ACTION_RENAMED_OLD_NAME: last_renamed_from... |
out_event_queue.put((event_handler, moved_event)) | out_event_queue.put((self.event_handler, moved_event)) | def queue_events(self, num_bytes, out_event_queue): with self._lock: # queue events last_renamed_from_filename = "" for action, filename in FILE_NOTIFY_INFORMATION(self.event_buffer.raw, num_bytes): filename = absolute_path(os.path.join(self.path, filename)) if action == FILE_ACTION_RENAMED_OLD_NAME: last_renamed_from... |
out_event_queue.put((event_handler, FileMovedEvent(last_renamed_from_filename, filename))) | out_event_queue.put((self.event_handler, FileMovedEvent(last_renamed_from_filename, filename))) | def queue_events(self, num_bytes, out_event_queue): with self._lock: # queue events last_renamed_from_filename = "" for action, filename in FILE_NOTIFY_INFORMATION(self.event_buffer.raw, num_bytes): filename = absolute_path(os.path.join(self.path, filename)) if action == FILE_ACTION_RENAMED_OLD_NAME: last_renamed_from... |
out_event_queue((event_handler, action_event_map[action](filename))) | out_event_queue.put((self.event_handler, action_event_map[action](filename))) | def queue_events(self, num_bytes, out_event_queue): with self._lock: # queue events last_renamed_from_filename = "" for action, filename in FILE_NOTIFY_INFORMATION(self.event_buffer.raw, num_bytes): filename = absolute_path(os.path.join(self.path, filename)) if action == FILE_ACTION_RENAMED_OLD_NAME: last_renamed_from... |
path = event.pathname new_path = event.src_pathname | path = event.src_pathname new_path = event.pathname | def process_IN_MOVED_TO(self, event): # TODO: Moved event on a directory does not fire moved event for # files inside the directory. Fix? path = event.pathname new_path = event.src_pathname if event.dir: self.event_handler.on_moved(DirMovedEvent(path, new_path=new_path)) else: self.event_handler.on_moved(FileMovedEvent... |
download_url="https://github.com/gorakhargosh/watchdog/tarball/v%s" % VERSION_STRING, | download_url="http://watchdog-python.googlecode.com/files/watchdog-%s.tar.gz" % VERSION_STRING, | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(os.path.join(os.path.dirname(__file__), filename)).read() |
packages=['watchdog'], | packages=find_packages(), | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() |
py_modules=[], | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() | |
paths_created = set() objects_deleted = set() | def dispatch_events(self, num_bytes): # dispatch events paths_created = set() objects_deleted = set() | |
elif action == FILE_ACTION_CREATED: paths_created.add(filename) elif action == FILE_ACTION_DELETED: paths_deleted.add(filename) | def dispatch_events(self, num_bytes): # dispatch events paths_created = set() objects_deleted = set() | |
""" | def dispatch_events(self, num_bytes): # dispatch events paths_created = set() objects_deleted = set() | |
return self.is_directory | return self._is_directory | def is_directory(self): return self.is_directory |
return self.path | return self._path @property def event_type(self): return self._event_type class FileSystemMovedEvent(FileSystemEvent): def __init__(self, path, new_path, is_directory=False): self._new_path = new_path FileSystemEvent.__init__(self, event_type=EVENT_TYPE_MOVED, path=path, is_directory=is_directory) | def path(self): return self.path |
@property def event_type(self): return self._event_type | def __repr__(self): return str((self.event_type, self.path, self.new_path, self.is_directory)) | def new_path(self): return self._new_path |
def __init__(self, path, *args, **kwargs): | def __init__(self, path): | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_DELETED, path=path) |
def __init__(self, path, *args, **kwargs): | def __init__(self, path): | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_MODIFIED, path=path) |
def __init__(self, path, *args, **kwargs): | def __init__(self, path): | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_CREATED, path=path) |
class FileMovedEvent(FileSystemEvent): def __init__(self, path, new_path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_MOVED, path=path) self._new_path = new_path @property def new_path(self): return self._new_path | class FileMovedEvent(FileSystemMovedEvent): pass | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_CREATED, path=path) |
def __init__(self, path, *args, **kwargs): | def __init__(self, path): | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_DELETED, path=path, is_directory=True) |
def __init__(self, path, *args, **kwargs): | def __init__(self, path): | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_MODIFIED, path=path, is_directory=True) |
def __init__(self, path, *args, **kwargs): | def __init__(self, path): | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_CREATED, path=path, is_directory=True) |
class DirMovedEvent(FileSystemEvent): def __init__(self, path, new_path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_MOVED, path=path, is_directory=True) self._new_path = new_path @property def new_path(self): return self._new_path | class DirMovedEvent(FileSystemMovedEvent): def __init__(self, path, new_path): FileSystemMovedEvent.__init__(self, path=path, new_path=new_path, is_directory=True) | def __init__(self, path, *args, **kwargs): FileSystemEvent.__init__(self, event_type=EVENT_TYPE_CREATED, path=path, is_directory=True) |
self.event_handler.dispath(moved_event) | self.event_handler.dispatch(moved_event) | def dispatch_events(self, num_bytes): # dispatch events last_renamed_from_filename = "" for action, filename in FILE_NOTIFY_INFORMATION(self.event_buffer.raw, num_bytes): filename = absolute_path(os.path.join(self.path, filename)) |
path = path.rstrip(path_separator) snapshot = self.snapshot_for_path[path] | (path, snapshot) = self._get_snapshot_for_path(path) | def _get_directory_snapshot_diff(self, path): """Obtains a diff of two directory snapshots.""" # Strip the path of the ending separator to ensure consistent keys # in the self.snapshot_for_path dictionary. path = path.rstrip(path_separator) snapshot = self.snapshot_for_path[path] new_snapshot = DirectorySnapshot(path) ... |
out_event_queue.put(FileMovedEvent(last_renamed_from_filename, filename, handler=self.event_handler))) | out_event_queue.put(FileMovedEvent(last_renamed_from_filename, filename, handler=self.event_handler)) | def queue_events(self, num_bytes, out_event_queue): with self._lock: # queue events last_renamed_from_filename = "" for action, filename in FILE_NOTIFY_INFORMATION(self.event_buffer.raw, num_bytes): filename = absolute_path(os.path.join(self.path, filename)) |
self.event_handler.on_created(DirCreatedEvent(src_path)) | self.event_handler.dispatch(DirCreatedEvent(src_path)) | def process_IN_CREATE(self, event): src_path = absolute_path(event.pathname) if event.dir: self.event_handler.on_created(DirCreatedEvent(src_path)) else: self.event_handler.on_created(FileCreatedEvent(src_path)) |
self.event_handler.on_created(FileCreatedEvent(src_path)) | self.event_handler.dispatch(FileCreatedEvent(src_path)) | def process_IN_CREATE(self, event): src_path = absolute_path(event.pathname) if event.dir: self.event_handler.on_created(DirCreatedEvent(src_path)) else: self.event_handler.on_created(FileCreatedEvent(src_path)) |
self.event_handler.on_deleted(DirDeletedEvent(src_path)) | self.event_handler.dispatch(DirDeletedEvent(src_path)) | def process_IN_DELETE(self, event): src_path = absolute_path(event.pathname) if event.dir: self.event_handler.on_deleted(DirDeletedEvent(src_path)) else: self.event_handler.on_deleted(FileDeletedEvent(src_path)) |
self.event_handler.on_deleted(FileDeletedEvent(src_path)) | self.event_handler.dispatch(FileDeletedEvent(src_path)) | def process_IN_DELETE(self, event): src_path = absolute_path(event.pathname) if event.dir: self.event_handler.on_deleted(DirDeletedEvent(src_path)) else: self.event_handler.on_deleted(FileDeletedEvent(src_path)) |
self.event_handler.on_modified(DirModifiedEvent(src_path)) | self.event_handler.dispatch(DirModifiedEvent(src_path)) | def process_IN_CLOSE_WRITE(self, event): src_path = absolute_path(event.pathname) if event.dir: self.event_handler.on_modified(DirModifiedEvent(src_path)) else: self.event_handler.on_modified(FileModifiedEvent(src_path)) |
self.event_handler.on_modified(FileModifiedEvent(src_path)) | self.event_handler.dispatch(FileModifiedEvent(src_path)) | def process_IN_CLOSE_WRITE(self, event): src_path = absolute_path(event.pathname) if event.dir: self.event_handler.on_modified(DirModifiedEvent(src_path)) else: self.event_handler.on_modified(FileModifiedEvent(src_path)) |
self.event_handler.on_moved(moved_event) self.event_handler.on_moved(DirMovedEvent(src_path, dest_path)) | self.event_handler.dispatch(moved_event) self.event_handler.dispatch(DirMovedEvent(src_path, dest_path)) | def process_IN_MOVED_TO(self, event): # TODO: Moved event on a directory does not fire moved event for # files inside the directory. Fix? src_path = absolute_path(event.src_pathname) dest_path = absolute_path(event.pathname) if event.dir: if self.is_recursive: for moved_event in get_moved_events_for(src_path, dest_path... |
self.event_handler.on_moved(FileMovedEvent(src_path, dest_path)) | self.event_handler.dispatch(FileMovedEvent(src_path, dest_path)) | def process_IN_MOVED_TO(self, event): # TODO: Moved event on a directory does not fire moved event for # files inside the directory. Fix? src_path = absolute_path(event.src_pathname) dest_path = absolute_path(event.pathname) if event.dir: if self.is_recursive: for moved_event in get_moved_events_for(src_path, dest_path... |
def observe_with(identifier, event_handler, paths, recursive): | def observe_with(observer, identifier, event_handler, paths, recursive): | def observe_with(identifier, event_handler, paths, recursive): """Single observer given an identifier, event handler, and directories to watch.""" o = Observer() o.schedule(identifier, event_handler, paths, recursive) o.start() try: while True: time.sleep(1) except KeyboardInterrupt: o.unschedule(identifier) o.stop() o... |
o = Observer() o.schedule(identifier, event_handler, paths, recursive) o.start() | observer.schedule(identifier, event_handler, paths, recursive) observer.start() | def observe_with(identifier, event_handler, paths, recursive): """Single observer given an identifier, event handler, and directories to watch.""" o = Observer() o.schedule(identifier, event_handler, paths, recursive) o.start() try: while True: time.sleep(1) except KeyboardInterrupt: o.unschedule(identifier) o.stop() o... |
o.unschedule(identifier) o.stop() o.join() | observer.unschedule(identifier) observer.stop() observer.join() | def observe_with(identifier, event_handler, paths, recursive): """Single observer given an identifier, event handler, and directories to watch.""" o = Observer() o.schedule(identifier, event_handler, paths, recursive) o.start() try: while True: time.sleep(1) except KeyboardInterrupt: o.unschedule(identifier) o.stop() o... |
observe_with('logger', event_handler, args.directories, args.recursive) | if args.debug_force_polling: from watchdog.observers.polling_observer import PollingObserver observer = PollingObserver() else: observer = Observer() observe_with(observer, 'logger', event_handler, args.directories, args.recursive) | def log(args): from watchdog.tricks import LoggerTrick patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) event_handler = LoggerTrick(patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories) observe_with('logger', event_handler, args.directories, args.... |
observe_with('shell-command', event_handler, watch_directories, args.recursive) | observe_with(Observer(), 'shell-command', event_handler, watch_directories, args.recursive) | def shell_command(args): from watchdog.tricks import ShellCommandTrick if not args.command: args.command = None else: args.command = args.command[0] patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) watch_directories = path_split(args.watch_directories) event_handler = ShellCommandTrick(... |
common_install_requires = ['PyYAML (>=3.09)', 'argh (>=0.8.1)'] | common_install_requires = ['PyYAML >=3.09', 'argh >=0.8.1'] | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() |
common_install_requires.append('select_backport (>=0.2)') common_install_requires.append('argparse (>=1.1)') | common_install_requires.append('select_backport >=0.2') common_install_requires.append('argparse >=1.1') | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() |
PLATFORM_LINUX: ['pyinotify (>=0.9.1)'], PLATFORM_WINDOWS: ['pywin32 (>=214)'], | PLATFORM_LINUX: ['pyinotify >=0.9.1'], PLATFORM_WINDOWS: ['pywin32 >=214'], | def read_file(filename): """Reads the contents of a given file and returns it.""" return open(path_join(dirname(__file__), filename)).read() |
what = "directory" if event.is_directory else "file" logging.debug('Moved %s: %s to %s', what, event.path, event.new_path) | logging.debug(event) pass | def on_moved(self, event): what = "directory" if event.is_directory else "file" logging.debug('Moved %s: %s to %s', what, event.path, event.new_path) |
what = "directory" if event.is_directory else "file" logging.debug('Created %s: %s', what, event.path) | logging.debug(event) pass | def on_created(self, event): what = "directory" if event.is_directory else "file" logging.debug('Created %s: %s', what, event.path) |
what = "directory" if event.is_directory else "file" logging.debug('Deleted %s: %s', what, event.path) | logging.debug(event) pass | def on_deleted(self, event): what = "directory" if event.is_directory else "file" logging.debug('Deleted %s: %s', what, event.path) |
what = "directory" if event.is_directory else "file" logging.debug('Modified %s: %s', what, event.path) | logging.debug(event) pass | def on_modified(self, event): what = "directory" if event.is_directory else "file" logging.debug('Modified %s: %s', what, event.path) |
logging.debug('Executing rule: %s for event: %s', rule_path, str(event)) | event_handler = self.rules[rule_path]['event_handler'] event_handler.dispatch(event) | def run(self): for t in self.event_producer_threads: t.start() try: while True: (rule_path, event) = self.event_queue.get() #self.rules[rule_path] logging.debug('Executing rule: %s for event: %s', rule_path, str(event)) except KeyboardInterrupt: t.stop() |
self._lock = threading.Lock() | self._lock = threading.RLock() | def __init__(self): # Set of KeventDescriptor self._descriptors = set() |
return self.__getitem__(path) def __getitem__(self, path): """ Obtains a :class:`KeventDescriptor` object for the specified path. :param path: Path for which the descriptor will be obtained. """ | def get(self, path): """ Obtains a :class:`KeventDescriptor` object for the specified path. | |
self._remove_descriptor(self[path]) | descriptor = self.get(path) self._remove_descriptor(descriptor) | def remove(self, path): """ Removes the :class:`KeventDescriptor` object for the given path if it already exists. |
with self._lock: if event.event_type == EVENT_TYPE_MOVED: self._unregister_kevent(event.src_path) self._register_kevent(event.dest_path, event.is_directory) elif event.event_type == EVENT_TYPE_DELETED: self._unregister_kevent(event.src_path) EventEmitter.queue_event(self, event) | EventEmitter.queue_event(self, event) if event.event_type == EVENT_TYPE_CREATED: self._register_kevent(event.src_path, event.is_directory) elif event.event_type == EVENT_TYPE_MOVED: self._unregister_kevent(event.src_path) self._register_kevent(event.dest_path, event.is_directory) elif event.event_type == EVENT_TYPE_DEL... | def queue_event(self, event): """ Handles queueing a single event object. |
if self.watch.is_recursive: for sub_event in event.sub_moved_events(): self.queue_event(sub_event) self.queue_event(event) | def _queue_renamed(self, src_path, is_directory, ref_snapshot, new_snapshot): """ Compares information from two directory snapshots (one taken before the rename operation and another taken right after) to determine the destination path of the file system object renamed, and adds appropriate events to the event queue. "... | |
event = FileMovedEvent(src_path, dest_path) self.queue_event(event) | self.queue_event(FileMovedEvent(src_path, dest_path)) | def _queue_renamed(self, src_path, is_directory, ref_snapshot, new_snapshot): """ Compares information from two directory snapshots (one taken before the rename operation and another taken right after) to determine the destination path of the file system object renamed, and adds appropriate events to the event queue. "... |
max_events=MAX_EVENTS, timeout=timeout) | MAX_EVENTS, timeout) | def _read_events(self, timeout=None): """ Reads events from a call to the blocking :meth:`select.kqueue.control()` method. |
event_list = self._read_events(timeout=timeout) | event_list = self._read_events(timeout) | def queue_events(self, timeout): """ Queues events by reading them from a call to the blocking :meth:`select.kqueue.control()` method. |
self.rules[path]['event_producer_thread'].stop() | o = self.rules.pop(path) o['event_producer_thread'].stop() | def remove_rule(self, path): if path in self.rules: self.rules[path]['event_producer_thread'].stop() |
return (event.src_path, event.event_type, event.is_directory) in self.all_items: | return (event.src_path, event.event_type, event.is_directory) in self.all_items | def _exists_in_set(self, event): return (event.src_path, event.event_type, event.is_directory) in self.all_items: |
logging.debug(e) | logging.warn(e) | def stop(self): self.stopped.set() # Close all open file descriptors for fd in self.descriptor_list: try: os.close(fd) except OSError, e: logging.debug(e) |
logging.debug(e) | logging.warn(e) | def unregister_path(self, path): path = path.rstrip(os.path.sep) if path in self.fso_table: fso = self.fso_table[path] self.kevent_list.remove(fso.kev) del self.fso_table[path] del self.fso_table[fso.fd] try: os.close(fso.fd) except OSError, e: logging.debug(e) self.descriptor_list.remove(fso.fd) |
@synchronized() def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) | def __process_kevents_except_movement(self, event_list, out_event_queue): | def register_path(self, path, is_directory=False): """Call from within a synchronized method.""" path = path.rstrip(os.path.sep) if not path in self.fso_table: # If we haven't registered a kevent for this path already, # add a new kevent for the path. kev, fd = create_kevent_for_path(path) self.kevent_list.append(kev) ... |
q = self.out_event_queue | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) | |
q.put((self.path, event)) | out_event_queue.put((self.path, event)) | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) |
event = FileModifiedEvent(src_path=src_path) q.put((self.path, event)) | out_event_queue.put((self.path, FileModifiedEvent(src_path=src_path))) | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) |
for path_renamed in files_renamed: ref_stat_info = ref_dir_snapshot.stat_info(path_renamed) try: path = new_dir_snapshot.path_for_inode(ref_stat_info.st_ino) event = FileMovedEvent(src_path=path_renamed, dest_path=path) q.put((self.path, event)) self.unregister_path(path_renamed) self.register_path(path, is_directory... | self.__process_kevent_file_renames(out_event_queue, ref_dir_snapshot, new_dir_snapshot, files_renamed) self.__process_kevent_dir_renames(out_event_queue, ref_dir_snapshot, new_dir_snapshot, dirs_renamed) | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) |
for dir_modified in dirs_modified: event = DirModifiedEvent(src_path=dir_modified) q.put((self.path, event)) diff = new_dir_snapshot - ref_dir_snapshot for file_created in diff.files_created: event = FileCreatedEvent(src_path=file_created) q.put((self.path, event)) self.register_path(file_created, is_directory=False)... | self.__process_kevent_dir_modifications(out_event_queue, ref_dir_snapshot, new_dir_snapshot, dirs_modified) | def process_events(self): event_list = self.kq.control(list(self.kevent_list), MAX_EVENTS) |
self.process_events() | self.process_events(self.out_event_queue) | def run(self): self.register_dir_tree(self.path, self.is_recursive) while not self.stopped.is_set(): try: #if not os.path.exists(self.path): # self.stop() # continue self.process_events() except OSError, e: if e.errno == errno.EBADF: # select.kqueue seems to be blowing up on the first # call to kqueue.control wit... |
self.DebugErr(e) | self.Debug(e) | def lookup_ciba(self, word): try: response = urllib.urlopen("http://www.iciba.com/%s/" % urllib.quote(word.encode("UTF-8"))) except Exception, e: self.DebugErr(e) return "error" else: # Do the parsing here html = response.read().decode("UTF-8", "ignore") if self.iciba_rNx.search(html): return "" m = self.iciba_rCtoE.s... |
self.DebugErr(loc) | self.Debug(loc) | def lookup_yahoo(self, word): connect = httplib.HTTPConnection('cn.yahoo.com', 80) w = word.encode("GBK") # better than error connect.request("GET", "/dictionary/result/%s/%s.html" % (w[0], w)) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.... |
html = html.replace('\n', '') | import HTMLParser html = HTMLParser.HTMLParser().unescape(html).replace('\n', '') | def translate(self, text, fromLang, toLang, fromLanguage, toLanguage): if fromLanguage == 'cht' or toLanguage == 'cht': big5 = 'yes' else: big5 = 'no' translation = fromLang + toLang import irclib if translation not in self.supportedTranslations: irclib.DebugErr(translation) return if translation in self.encodings: enc... |
translated = json.loads(response.read().decode("UTF-8", "ignore").replace(']],,"', ']],[],"')) | result = response.read().decode("UTF-8", "ignore") result = result.replace('[,', '[[],').replace(',]', ',[]]') while ',,' in result: result = result.replace(',,', ',[],') import irclib irclib.DebugErr(result) translated = json.loads(result) | def translate(self, text, fromLang, toLang, fromLanguage, toLanguage): if fromLang not in self.supportedTranslations or toLang not in self.supportedTranslations: return |
return result[0] + ' ' + result[2] | return result[0].replace(',[],', ',,') + ' ' + result[2].replace(',[],', ',,') | def translate(self, text, fromLang, toLang, fromLanguage, toLanguage): if fromLang not in self.supportedTranslations or toLang not in self.supportedTranslations: return |
self.DebugErr(e) | self.Debug(e) | def handler(self, **args): |
self.DebugErr(e) | self.Debug(e) | def handler(self, **args): target = self.return_to_sender(args) self.version = ['oldstable', 'stable', 'testing', 'unstable'] request = args["text"].split()[2:] if request[0] in self.version: self.version = request[0] del request[0] else: self.version = "testing" if len(request) != 1: msg = "Usage: debfile [oldstable|... |
rResult = re.compile('<textarea[^>]+id="after"[^>]+>(.*?)</textarea>') | rResult = re.compile('<textarea[^>]+id="after"[^>]*>(.*?)</textarea>') | def translate(self, text, fromLang, toLang, fromLanguage, toLanguage): pass |
self.cmap = {"\\\\": "\\", "5": "'", "E": "2"} self.rNx = re.compile(u"Ҳѯ") self.rCtoE = re.compile(u"Ӣʵ") self.rRwWord = re.compile('rwWord\("([^"]+)"\)') self.rEtoC = re.compile(u"Ӣʵ") self.rExplain = re.compile('explain_item">(.*?)</div>', re.S) self.rSpell = re.compile("str2img\('([^']+)", re.I) | def __init__(self): # have problem filtering out `|' character self.regex = "^(dict |~)[^~\+\*/\\<>-]+" self.rStrip = re.compile("(<.*?>)+") self.rWord = re.compile("^<!-- WORD", re.I) self.rGif = re.compile("/gif/([\\w_]+)\\.gif", re.I) self.rBody = re.compile("^<!-- BODY", re.I) self.ymap = {"slash": "/", "quote": "... | |
self.Debug(words) | def handler(self, **args): import dict target = self.return_to_sender(args) if args["text"].split()[1][0][0] == '~': word = " ".join(args["text"].split()[1:])[1:] else: word = " ".join(args["text"].split()[2:]) | |
result = self.lookup_ciba(word) | if self.ciba_failed <= 0: result = self.lookup_ciba(word) if result == "error": self.ciba_failed = 5 result = self.lookup_yahoo(word) else: result = self.lookup_yahoo(word) self.ciba_failed = self.ciba_failed - 1 | def handler(self, **args): import dict target = self.return_to_sender(args) if args["text"].split()[1][0][0] == '~': word = " ".join(args["text"].split()[1:])[1:] else: word = " ".join(args["text"].split()[2:]) |
connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.Debug("dict word(%s) err(%s) ... | try: response = urllib.urlopen("http://www.iciba.com/%s/" % urllib.quote(word.encode("UTF-8"))) except Exception, e: self.DebugErr(e) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
if self.rNx.search(html): | if self.iciba_rNx.search(html): | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
m = self.rCtoE.search(html) | m = self.iciba_rCtoE.search(html) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
m = self.rRwWord.findall(html) | m = self.iciba_rRwWord.findall(html) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
m = self.rEtoC.search(html) | m = self.iciba_rEtoC.search(html) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
m = self.rSpell.search(html) | m = self.iciba_rSpell.search(html) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
for k in self.cmap: spell = spell.replace(k, self.cmap[k]) | for k in self.iciba_cmap: spell = spell.replace(k, self.iciba_cmap[k]) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
m = self.rExplain.search(html) | m = self.iciba_rExplain.search(html) | def lookup_ciba(self, word): connect = httplib.HTTPConnection('www.iciba.com', 80) connect.request("GET", "/search?s=%s&t=word&lang=utf-8" % (word.encode("UTF-8"), )) response = connect.getresponse() if response.status != 200: msg = "%d:%s" % (response.status, response.reason) loc = response.getheader("location") self.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.