Skip to content

Commit

Permalink
Revert "Added InputFileParameter and OutputFileParameter classes." (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarrasch authored Aug 4, 2016
1 parent 59614c9 commit 8545d6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
6 changes: 2 additions & 4 deletions luigi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
DateParameter, MonthParameter, YearParameter, DateHourParameter, DateMinuteParameter, DateSecondParameter,
DateIntervalParameter, TimeDeltaParameter,
IntParameter, FloatParameter, BooleanParameter, BoolParameter,
TaskParameter, EnumParameter, DictParameter, ListParameter, TupleParameter,
InputFileParameter, OutputFileParameter
TaskParameter, EnumParameter, DictParameter, ListParameter, TupleParameter
)

from luigi import configuration
Expand All @@ -58,6 +57,5 @@
'DateIntervalParameter', 'TimeDeltaParameter', 'IntParameter',
'FloatParameter', 'BooleanParameter', 'BoolParameter', 'TaskParameter',
'ListParameter', 'TupleParameter', 'EnumParameter', 'DictParameter',
'configuration', 'interface', 'file', 'run', 'build', 'event', 'Event',
'InputFileParameter', 'OutputFileParameter'
'configuration', 'interface', 'file', 'run', 'build', 'event', 'Event'
]
36 changes: 0 additions & 36 deletions luigi/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import operator
import functools
from ast import literal_eval
import os

try:
from ConfigParser import NoOptionError, NoSectionError
Expand Down Expand Up @@ -960,38 +959,3 @@ def serialize(self, x):
:param x: the value to serialize.
"""
return json.dumps(x)


class InputFileParameter(Parameter):
"""
Paramater whose value is an existing file.
"""

def parse(self, s):
"""
Returns the real path to the file from the string if it exists.
"""
if os.path.isfile(s):
return os.path.realpath(s)
else:
raise OSError("{s} does not exist".format(s=s))


class OutputFileParameter(Parameter):
"""
Parameter whose value is an output file to be created.
"""

def parse(self, s):
"""
Returns the real path to the file and attempts to create any directories
needed.
"""
s = os.path.realpath(s)
if not os.path.isdir(os.path.dirname(s)):
try:
os.makedirs(os.path.dirname(s))
except OSError:
raise OSError("could not make parent directories for {s}".format(
s=s))
return s

0 comments on commit 8545d6e

Please sign in to comment.