From 5e7c42241cd96593989c837fd229f1078bcc047b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Mon, 27 Apr 2015 13:09:48 +0200 Subject: [PATCH] pep8 fixes --- luigi/file.py | 3 +++ luigi/target.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/luigi/file.py b/luigi/file.py index 521913674c..c7e80ed2d9 100644 --- a/luigi/file.py +++ b/luigi/file.py @@ -32,7 +32,9 @@ from luigi.target import FileSystem, FileSystemTarget, AtomicLocalFile from luigi.target import AtomicLocalFileAppend + class atomic_file(AtomicLocalFile): + """Simple class that writes to a temp file and moves it on close() Also cleans up the temp file if close is not invoked """ @@ -45,6 +47,7 @@ def generate_tmp_path(self, path): class LocalFileSystem(FileSystem): + """ Wrapper for access to file system operations. diff --git a/luigi/target.py b/luigi/target.py index 8b2f92090b..75348d0ffc 100644 --- a/luigi/target.py +++ b/luigi/target.py @@ -38,6 +38,7 @@ class FileLockException(Exception): @six.add_metaclass(abc.ABCMeta) class Target(object): + """ A Target is a resource generated by a :py:class:`~luigi.task.Task`. @@ -58,6 +59,7 @@ def exists(self): class FileSystemException(Exception): + """ Base class for generic file system exceptions. """ @@ -65,6 +67,7 @@ class FileSystemException(Exception): class FileAlreadyExists(FileSystemException): + """ Raised when a file system operation can't be performed because a directory exists but is required to not exist. @@ -73,6 +76,7 @@ class FileAlreadyExists(FileSystemException): class MissingParentDirectory(FileSystemException): + """ Raised when a parent directory doesn't exist. (Imagine mkdir without -p) @@ -82,6 +86,7 @@ class MissingParentDirectory(FileSystemException): @six.add_metaclass(abc.ABCMeta) class FileSystem(object): + """ FileSystem abstraction used in conjunction with :py:class:`FileSystemTarget`. @@ -141,10 +146,13 @@ def isdir(self, path): *Note*: This method is optional, not all FileSystem subclasses implements it. """ - raise NotImplementedError("isdir() not implemented on {0}".format(self.__class__.__name__)) + raise NotImplementedError( + "isdir() not implemented on {0}".format( + self.__class__.__name__)) class FileSystemTarget(Target): + """ Base class for FileSystem Targets like :class:`~luigi.file.LocalTarget` and :class:`~luigi.contrib.hdfs.HdfsTarget`. @@ -207,6 +215,7 @@ def remove(self): class AtomicLocalFile(io.BufferedWriter): + """Abstract class to create Target that create a tempoprary file in the local filesystem before moving it to there final destination @@ -244,7 +253,9 @@ def __exit__(self, exc_type, exc, traceback): return return super(AtomicLocalFile, self).__exit__(exc_type, exc, traceback) + class AtomicLocalFileAppend(io.BufferedWriter): + def __init__(self, path, timeout=10, delay=.05): self.path = path self.is_locked = False