Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster/dagster/seven/__init__.py
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | else: | ||||
return pytz.utc | return pytz.utc | ||||
def get_current_datetime_in_utc(): | def get_current_datetime_in_utc(): | ||||
return datetime.datetime.now(tz=get_utc_timezone()) | return datetime.datetime.now(tz=get_utc_timezone()) | ||||
def get_timestamp_from_utc_datetime(utc_datetime): | |||||
if utc_datetime.tzinfo != get_utc_timezone(): | |||||
raise Exception("Must pass in a UTC timezone to compute UNIX timestamp") | |||||
if sys.version_info.major >= 3 and sys.version_info.minor >= 2: | |||||
return utc_datetime.timestamp() | |||||
else: | |||||
import pytz | |||||
return (utc_datetime - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds() | |||||
def is_lambda(target): | def is_lambda(target): | ||||
return callable(target) and (hasattr(target, "__name__") and target.__name__ == "<lambda>") | return callable(target) and (hasattr(target, "__name__") and target.__name__ == "<lambda>") | ||||
def is_function_or_decorator_instance_of(target, kls): | def is_function_or_decorator_instance_of(target, kls): | ||||
return inspect.isfunction(target) or (isinstance(target, kls) and hasattr(target, "__name__")) | return inspect.isfunction(target) or (isinstance(target, kls) and hasattr(target, "__name__")) | ||||
Show All 16 Lines |