repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
harisbal/pandas
pandas/core/tools/datetimes.py
4
30680
from functools import partial from datetime import datetime, time from collections import MutableMapping import numpy as np from pandas._libs import tslib, tslibs from pandas._libs.tslibs.strptime import array_strptime from pandas._libs.tslibs import parsing, conversion, Timestamp from pandas._libs.tslibs.parsing import ( # noqa parse_time_string, DateParseError, _format_is_iso, _guess_datetime_format) from pandas.core.dtypes.common import ( ensure_object, is_datetime64_ns_dtype, is_datetime64_dtype, is_datetime64tz_dtype, is_integer_dtype, is_integer, is_float, is_list_like, is_scalar, is_numeric_dtype, is_object_dtype) from pandas.core.dtypes.generic import ( ABCIndexClass, ABCSeries, ABCDataFrame) from pandas.core.dtypes.missing import notna from pandas.core import algorithms from pandas.compat import zip def _guess_datetime_format_for_array(arr, **kwargs): # Try to guess the format based on the first non-NaN element non_nan_elements = notna(arr).nonzero()[0] if len(non_nan_elements): return _guess_datetime_format(arr[non_nan_elements[0]], **kwargs) def _maybe_cache(arg, format, cache, convert_listlike): """ Create a cache of unique dates from an array of dates Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series format : string Strftime format to parse time cache : boolean True attempts to create a cache of converted values convert_listlike : function Conversion function to apply on dates Returns ------- cache_array : Series Cache of converted, unique dates. Can be empty """ from pandas import Series cache_array = Series() if cache: # Perform a quicker unique check from pandas import Index if not Index(arg).is_unique: unique_dates = algorithms.unique(arg) cache_dates = convert_listlike(unique_dates, True, format) cache_array = Series(cache_dates, index=unique_dates) return cache_array def _convert_and_box_cache(arg, cache_array, box, errors, name=None): """ Convert array of dates with a cache and box the result Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series cache_array : Series Cache of converted, unique dates box : boolean True boxes result as an Index-like, False returns an ndarray errors : string 'ignore' plus box=True will convert result to Index name : string, default None Name for a DatetimeIndex Returns ------- result : datetime of converted dates Returns: - Index-like if box=True - ndarray if box=False """ from pandas import Series, DatetimeIndex, Index result = Series(arg).map(cache_array) if box: if errors == 'ignore': return Index(result, name=name) else: return DatetimeIndex(result, name=name) return result.values def _return_parsed_timezone_results(result, timezones, box, tz, name): """ Return results from array_strptime if a %z or %Z directive was passed. Parameters ---------- result : ndarray int64 date representations of the dates timezones : ndarray pytz timezone objects box : boolean True boxes result as an Index-like, False returns an ndarray tz : object None or pytz timezone object name : string, default None Name for a DatetimeIndex Returns ------- tz_result : ndarray of parsed dates with timezone Returns: - Index-like if box=True - ndarray of Timestamps if box=False """ if tz is not None: raise ValueError("Cannot pass a tz argument when " "parsing strings with timezone " "information.") tz_results = np.array([Timestamp(res).tz_localize(zone) for res, zone in zip(result, timezones)]) if box: from pandas import Index return Index(tz_results, name=name) return tz_results def _convert_listlike_datetimes(arg, box, format, name=None, tz=None, unit=None, errors=None, infer_datetime_format=None, dayfirst=None, yearfirst=None, exact=None): """ Helper function for to_datetime. Performs the conversions of 1D listlike of dates Parameters ---------- arg : list, tuple, ndarray, Series, Index date to be parced box : boolean True boxes result as an Index-like, False returns an ndarray name : object None or string for the Index name tz : object None or 'utc' unit : string None or string of the frequency of the passed data errors : string error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore' infer_datetime_format : boolean inferring format behavior from to_datetime dayfirst : boolean dayfirst parsing behavior from to_datetime yearfirst : boolean yearfirst parsing behavior from to_datetime exact : boolean exact format matching behavior from to_datetime Returns ------- ndarray of parsed dates Returns: - Index-like if box=True - ndarray of Timestamps if box=False """ from pandas import DatetimeIndex if isinstance(arg, (list, tuple)): arg = np.array(arg, dtype='O') # these are shortcutable if is_datetime64tz_dtype(arg): if not isinstance(arg, DatetimeIndex): return DatetimeIndex(arg, tz=tz, name=name) if tz == 'utc': arg = arg.tz_convert(None).tz_localize(tz) return arg elif is_datetime64_ns_dtype(arg): if box and not isinstance(arg, DatetimeIndex): try: return DatetimeIndex(arg, tz=tz, name=name) except ValueError: pass return arg elif unit is not None: if format is not None: raise ValueError("cannot specify both format and unit") arg = getattr(arg, 'values', arg) result = tslib.array_with_unit_to_datetime(arg, unit, errors=errors) if box: if errors == 'ignore': from pandas import Index return Index(result, name=name) return DatetimeIndex(result, tz=tz, name=name) return result elif getattr(arg, 'ndim', 1) > 1: raise TypeError('arg must be a string, datetime, list, tuple, ' '1-d array, or Series') arg = ensure_object(arg) require_iso8601 = False if infer_datetime_format and format is None: format = _guess_datetime_format_for_array(arg, dayfirst=dayfirst) if format is not None: # There is a special fast-path for iso8601 formatted # datetime strings, so in those cases don't use the inferred # format because this path makes process slower in this # special case format_is_iso8601 = _format_is_iso(format) if format_is_iso8601: require_iso8601 = not infer_datetime_format format = None try: result = None if format is not None: # shortcut formatting here if format == '%Y%m%d': try: result = _attempt_YYYYMMDD(arg, errors=errors) except (ValueError, TypeError, tslibs.OutOfBoundsDatetime): raise ValueError("cannot convert the input to " "'%Y%m%d' date format") # fallback if result is None: try: result, timezones = array_strptime( arg, format, exact=exact, errors=errors) if '%Z' in format or '%z' in format: return _return_parsed_timezone_results( result, timezones, box, tz, name) except tslibs.OutOfBoundsDatetime: if errors == 'raise': raise result = arg except ValueError: # if format was inferred, try falling back # to array_to_datetime - terminate here # for specified formats if not infer_datetime_format: if errors == 'raise': raise result = arg if result is None and (format is None or infer_datetime_format): result, tz_parsed = tslib.array_to_datetime( arg, errors=errors, utc=tz == 'utc', dayfirst=dayfirst, yearfirst=yearfirst, require_iso8601=require_iso8601 ) if tz_parsed is not None: if box: # We can take a shortcut since the datetime64 numpy array # is in UTC return DatetimeIndex._simple_new(result, name=name, tz=tz_parsed) else: # Convert the datetime64 numpy array to an numpy array # of datetime objects result = [Timestamp(ts, tz=tz_parsed).to_pydatetime() for ts in result] return np.array(result, dtype=object) if box: # Ensure we return an Index in all cases where box=True if is_datetime64_dtype(result): return DatetimeIndex(result, tz=tz, name=name) elif is_object_dtype(result): # e.g. an Index of datetime objects from pandas import Index return Index(result, name=name) return result except ValueError as e: try: values, tz = conversion.datetime_to_datetime64(arg) return DatetimeIndex._simple_new(values, name=name, tz=tz) except (ValueError, TypeError): raise e def _adjust_to_origin(arg, origin, unit): """ Helper function for to_datetime. Adjust input argument to the specified origin Parameters ---------- arg : list, tuple, ndarray, Series, Index date to be adjusted origin : 'julian' or Timestamp origin offset for the arg unit : string passed unit from to_datetime, must be 'D' Returns ------- ndarray or scalar of adjusted date(s) """ if origin == 'julian': original = arg j0 = Timestamp(0).to_julian_date() if unit != 'D': raise ValueError("unit must be 'D' for origin='julian'") try: arg = arg - j0 except TypeError: raise ValueError("incompatible 'arg' type for given " "'origin'='julian'") # premptively check this for a nice range j_max = Timestamp.max.to_julian_date() - j0 j_min = Timestamp.min.to_julian_date() - j0 if np.any(arg > j_max) or np.any(arg < j_min): raise tslibs.OutOfBoundsDatetime( "{original} is Out of Bounds for " "origin='julian'".format(original=original)) else: # arg must be numeric if not ((is_scalar(arg) and (is_integer(arg) or is_float(arg))) or is_numeric_dtype(np.asarray(arg))): raise ValueError( "'{arg}' is not compatible with origin='{origin}'; " "it must be numeric with a unit specified ".format( arg=arg, origin=origin)) # we are going to offset back to unix / epoch time try: offset = Timestamp(origin) except tslibs.OutOfBoundsDatetime: raise tslibs.OutOfBoundsDatetime( "origin {origin} is Out of Bounds".format(origin=origin)) except ValueError: raise ValueError("origin {origin} cannot be converted " "to a Timestamp".format(origin=origin)) if offset.tz is not None: raise ValueError( "origin offset {} must be tz-naive".format(offset)) offset -= Timestamp(0) # convert the offset to the unit of the arg # this should be lossless in terms of precision offset = offset // tslibs.Timedelta(1, unit=unit) # scalars & ndarray-like can handle the addition if is_list_like(arg) and not isinstance( arg, (ABCSeries, ABCIndexClass, np.ndarray)): arg = np.asarray(arg) arg = arg + offset return arg def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False, utc=None, box=True, format=None, exact=True, unit=None, infer_datetime_format=False, origin='unix', cache=False): """ Convert argument to datetime. Parameters ---------- arg : integer, float, string, datetime, list, tuple, 1-d array, Series .. versionadded:: 0.18.1 or DataFrame/dict-like errors : {'ignore', 'raise', 'coerce'}, default 'raise' - If 'raise', then invalid parsing will raise an exception - If 'coerce', then invalid parsing will be set as NaT - If 'ignore', then invalid parsing will return the input dayfirst : boolean, default False Specify a date parse order if `arg` is str or its list-likes. If True, parses dates with the day first, eg 10/11/12 is parsed as 2012-11-10. Warning: dayfirst=True is not strict, but will prefer to parse with day first (this is a known bug, based on dateutil behavior). yearfirst : boolean, default False Specify a date parse order if `arg` is str or its list-likes. - If True parses dates with the year first, eg 10/11/12 is parsed as 2010-11-12. - If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil). Warning: yearfirst=True is not strict, but will prefer to parse with year first (this is a known bug, based on dateutil behavior). .. versionadded:: 0.16.1 utc : boolean, default None Return UTC DatetimeIndex if True (converting any tz-aware datetime.datetime objects as well). box : boolean, default True - If True returns a DatetimeIndex or Index-like object - If False returns ndarray of values. format : string, default None strftime to parse time, eg "%d/%m/%Y", note that "%f" will parse all the way up to nanoseconds. exact : boolean, True by default - If True, require an exact format match. - If False, allow the format to match anywhere in the target string. unit : string, default 'ns' unit of the arg (D,s,ms,us,ns) denote the unit, which is an integer or float number. This will be based off the origin. Example, with unit='ms' and origin='unix' (the default), this would calculate the number of milliseconds to the unix epoch start. infer_datetime_format : boolean, default False If True and no `format` is given, attempt to infer the format of the datetime strings, and if it can be inferred, switch to a faster method of parsing them. In some cases this can increase the parsing speed by ~5-10x. origin : scalar, default is 'unix' Define the reference date. The numeric values would be parsed as number of units (defined by `unit`) since this reference date. - If 'unix' (or POSIX) time; origin is set to 1970-01-01. - If 'julian', unit must be 'D', and origin is set to beginning of Julian Calendar. Julian day number 0 is assigned to the day starting at noon on January 1, 4713 BC. - If Timestamp convertible, origin is set to Timestamp identified by origin. .. versionadded:: 0.20.0 cache : boolean, default False If True, use a cache of unique, converted dates to apply the datetime conversion. May produce significant speed-up when parsing duplicate date strings, especially ones with timezone offsets. .. versionadded:: 0.23.0 Returns ------- ret : datetime if parsing succeeded. Return type depends on input: - list-like: DatetimeIndex - Series: Series of datetime64 dtype - scalar: Timestamp In case when it is not possible to return designated types (e.g. when any element of input is before Timestamp.min or after Timestamp.max) return will have datetime.datetime type (or corresponding array/Series). Examples -------- Assembling a datetime from multiple columns of a DataFrame. The keys can be common abbreviations like ['year', 'month', 'day', 'minute', 'second', 'ms', 'us', 'ns']) or plurals of the same >>> df = pd.DataFrame({'year': [2015, 2016], 'month': [2, 3], 'day': [4, 5]}) >>> pd.to_datetime(df) 0 2015-02-04 1 2016-03-05 dtype: datetime64[ns] If a date does not meet the `timestamp limitations <http://pandas.pydata.org/pandas-docs/stable/timeseries.html #timeseries-timestamp-limits>`_, passing errors='ignore' will return the original input instead of raising any exception. Passing errors='coerce' will force an out-of-bounds date to NaT, in addition to forcing non-dates (or non-parseable dates) to NaT. >>> pd.to_datetime('13000101', format='%Y%m%d', errors='ignore') datetime.datetime(1300, 1, 1, 0, 0) >>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce') NaT Passing infer_datetime_format=True can often-times speedup a parsing if its not an ISO8601 format exactly, but in a regular format. >>> s = pd.Series(['3/11/2000', '3/12/2000', '3/13/2000']*1000) >>> s.head() 0 3/11/2000 1 3/12/2000 2 3/13/2000 3 3/11/2000 4 3/12/2000 dtype: object >>> %timeit pd.to_datetime(s,infer_datetime_format=True) 100 loops, best of 3: 10.4 ms per loop >>> %timeit pd.to_datetime(s,infer_datetime_format=False) 1 loop, best of 3: 471 ms per loop Using a unix epoch time >>> pd.to_datetime(1490195805, unit='s') Timestamp('2017-03-22 15:16:45') >>> pd.to_datetime(1490195805433502912, unit='ns') Timestamp('2017-03-22 15:16:45.433502912') .. warning:: For float arg, precision rounding might happen. To prevent unexpected behavior use a fixed-width exact type. Using a non-unix epoch origin >>> pd.to_datetime([1, 2, 3], unit='D', origin=pd.Timestamp('1960-01-01')) 0 1960-01-02 1 1960-01-03 2 1960-01-04 See also -------- pandas.DataFrame.astype : Cast argument to a specified dtype. pandas.to_timedelta : Convert argument to timedelta. """ if arg is None: return None if origin != 'unix': arg = _adjust_to_origin(arg, origin, unit) tz = 'utc' if utc else None convert_listlike = partial(_convert_listlike_datetimes, tz=tz, unit=unit, dayfirst=dayfirst, yearfirst=yearfirst, errors=errors, exact=exact, infer_datetime_format=infer_datetime_format) if isinstance(arg, Timestamp): result = arg elif isinstance(arg, ABCSeries): cache_array = _maybe_cache(arg, format, cache, convert_listlike) if not cache_array.empty: result = arg.map(cache_array) else: from pandas import Series values = convert_listlike(arg._values, True, format) result = Series(values, index=arg.index, name=arg.name) elif isinstance(arg, (ABCDataFrame, MutableMapping)): result = _assemble_from_unit_mappings(arg, errors=errors) elif isinstance(arg, ABCIndexClass): cache_array = _maybe_cache(arg, format, cache, convert_listlike) if not cache_array.empty: result = _convert_and_box_cache(arg, cache_array, box, errors, name=arg.name) else: convert_listlike = partial(convert_listlike, name=arg.name) result = convert_listlike(arg, box, format) elif is_list_like(arg): cache_array = _maybe_cache(arg, format, cache, convert_listlike) if not cache_array.empty: result = _convert_and_box_cache(arg, cache_array, box, errors) else: result = convert_listlike(arg, box, format) else: result = convert_listlike(np.array([arg]), box, format)[0] return result # mappings for assembling units _unit_map = {'year': 'year', 'years': 'year', 'month': 'month', 'months': 'month', 'day': 'day', 'days': 'day', 'hour': 'h', 'hours': 'h', 'minute': 'm', 'minutes': 'm', 'second': 's', 'seconds': 's', 'ms': 'ms', 'millisecond': 'ms', 'milliseconds': 'ms', 'us': 'us', 'microsecond': 'us', 'microseconds': 'us', 'ns': 'ns', 'nanosecond': 'ns', 'nanoseconds': 'ns' } def _assemble_from_unit_mappings(arg, errors): """ assemble the unit specified fields from the arg (DataFrame) Return a Series for actual parsing Parameters ---------- arg : DataFrame errors : {'ignore', 'raise', 'coerce'}, default 'raise' - If 'raise', then invalid parsing will raise an exception - If 'coerce', then invalid parsing will be set as NaT - If 'ignore', then invalid parsing will return the input Returns ------- Series """ from pandas import to_timedelta, to_numeric, DataFrame arg = DataFrame(arg) if not arg.columns.is_unique: raise ValueError("cannot assemble with duplicate keys") # replace passed unit with _unit_map def f(value): if value in _unit_map: return _unit_map[value] # m is case significant if value.lower() in _unit_map: return _unit_map[value.lower()] return value unit = {k: f(k) for k in arg.keys()} unit_rev = {v: k for k, v in unit.items()} # we require at least Ymd required = ['year', 'month', 'day'] req = sorted(list(set(required) - set(unit_rev.keys()))) if len(req): raise ValueError("to assemble mappings requires at least that " "[year, month, day] be specified: [{required}] " "is missing".format(required=','.join(req))) # keys we don't recognize excess = sorted(list(set(unit_rev.keys()) - set(_unit_map.values()))) if len(excess): raise ValueError("extra keys have been passed " "to the datetime assemblage: " "[{excess}]".format(excess=','.join(excess))) def coerce(values): # we allow coercion to if errors allows values = to_numeric(values, errors=errors) # prevent overflow in case of int8 or int16 if is_integer_dtype(values): values = values.astype('int64', copy=False) return values values = (coerce(arg[unit_rev['year']]) * 10000 + coerce(arg[unit_rev['month']]) * 100 + coerce(arg[unit_rev['day']])) try: values = to_datetime(values, format='%Y%m%d', errors=errors) except (TypeError, ValueError) as e: raise ValueError("cannot assemble the " "datetimes: {error}".format(error=e)) for u in ['h', 'm', 's', 'ms', 'us', 'ns']: value = unit_rev.get(u) if value is not None and value in arg: try: values += to_timedelta(coerce(arg[value]), unit=u, errors=errors) except (TypeError, ValueError) as e: raise ValueError("cannot assemble the datetimes [{value}]: " "{error}".format(value=value, error=e)) return values def _attempt_YYYYMMDD(arg, errors): """ try to parse the YYYYMMDD/%Y%m%d format, try to deal with NaT-like, arg is a passed in as an object dtype, but could really be ints/strings with nan-like/or floats (e.g. with nan) Parameters ---------- arg : passed value errors : 'raise','ignore','coerce' """ def calc(carg): # calculate the actual result carg = carg.astype(object) parsed = parsing.try_parse_year_month_day(carg / 10000, carg / 100 % 100, carg % 100) return tslib.array_to_datetime(parsed, errors=errors)[0] def calc_with_mask(carg, mask): result = np.empty(carg.shape, dtype='M8[ns]') iresult = result.view('i8') iresult[~mask] = tslibs.iNaT masked_result = calc(carg[mask].astype(np.float64).astype(np.int64)) result[mask] = masked_result.astype('M8[ns]') return result # try intlike / strings that are ints try: return calc(arg.astype(np.int64)) except ValueError: pass # a float with actual np.nan try: carg = arg.astype(np.float64) return calc_with_mask(carg, notna(carg)) except ValueError: pass # string with NaN-like try: mask = ~algorithms.isin(arg, list(tslib.nat_strings)) return calc_with_mask(arg, mask) except ValueError: pass return None # Fixed time formats for time parsing _time_formats = ["%H:%M", "%H%M", "%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p", "%I%M%S%p"] def _guess_time_format_for_array(arr): # Try to guess the format based on the first non-NaN element non_nan_elements = notna(arr).nonzero()[0] if len(non_nan_elements): element = arr[non_nan_elements[0]] for time_format in _time_formats: try: datetime.strptime(element, time_format) return time_format except ValueError: pass return None def to_time(arg, format=None, infer_time_format=False, errors='raise'): """ Parse time strings to time objects using fixed strptime formats ("%H:%M", "%H%M", "%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p", "%I%M%S%p") Use infer_time_format if all the strings are in the same format to speed up conversion. Parameters ---------- arg : string in time format, datetime.time, list, tuple, 1-d array, Series format : str, default None Format used to convert arg into a time object. If None, fixed formats are used. infer_time_format: bool, default False Infer the time format based on the first non-NaN element. If all strings are in the same format, this will speed up conversion. errors : {'ignore', 'raise', 'coerce'}, default 'raise' - If 'raise', then invalid parsing will raise an exception - If 'coerce', then invalid parsing will be set as None - If 'ignore', then invalid parsing will return the input Returns ------- datetime.time """ from pandas.core.series import Series def _convert_listlike(arg, format): if isinstance(arg, (list, tuple)): arg = np.array(arg, dtype='O') elif getattr(arg, 'ndim', 1) > 1: raise TypeError('arg must be a string, datetime, list, tuple, ' '1-d array, or Series') arg = ensure_object(arg) if infer_time_format and format is None: format = _guess_time_format_for_array(arg) times = [] if format is not None: for element in arg: try: times.append(datetime.strptime(element, format).time()) except (ValueError, TypeError): if errors == 'raise': msg = ("Cannot convert {element} to a time with given " "format {format}").format(element=element, format=format) raise ValueError(msg) elif errors == 'ignore': return arg else: times.append(None) else: formats = _time_formats[:] format_found = False for element in arg: time_object = None for time_format in formats: try: time_object = datetime.strptime(element, time_format).time() if not format_found: # Put the found format in front fmt = formats.pop(formats.index(time_format)) formats.insert(0, fmt) format_found = True break except (ValueError, TypeError): continue if time_object is not None: times.append(time_object) elif errors == 'raise': raise ValueError("Cannot convert arg {arg} to " "a time".format(arg=arg)) elif errors == 'ignore': return arg else: times.append(None) return times if arg is None: return arg elif isinstance(arg, time): return arg elif isinstance(arg, Series): values = _convert_listlike(arg._values, format) return Series(values, index=arg.index, name=arg.name) elif isinstance(arg, ABCIndexClass): return _convert_listlike(arg, format) elif is_list_like(arg): return _convert_listlike(arg, format) return _convert_listlike(np.array([arg]), format)[0]
bsd-3-clause
[ 504, 9143, 492, 7417, 199, 504, 2197, 492, 2197, 12, 900, 199, 504, 5055, 492, 29396, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 10634, 423, 8450, 492, 6714, 773, 12, 6714, 8450, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 9866, 492, 1625, 63, 9866, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 492, 6057, 12, 8603, 12, 18267, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 11059, 492, 334, 221, 327, 8151, 272, 2198, 63, 521, 63, 875, 12, 272, 6148, 9123, 12, 272, 485, 908, 63, 374, 63, 4595, 12, 272, 485, 11636, 63, 2083, 63, 908, 9, 199, 199, 504, 10634, 14, 1018, 14, 5717, 14, 2330, 492, 334, 272, 4868, 63, 785, 12, 272, 365, 63, 2083, 772, 63, 561, 63, 2271, 12, 272, 365, 63, 2083, 772, 63, 2271, 12, 272, 365, 63, 2083, 772, 3903, 63, 2271, 12, 272, 365, 63, 4115, 63, 2271, 12, 272, 365, 63, 4115, 12, 272, 365, 63, 1609, 12, 272, 365, 63, 513, 63, 2930, 12, 272, 365, 63, 7033, 12, 272, 365, 63, 6677, 63, 2271, 12, 272, 365, 63, 785, 63, 2271, 9, 199, 504, 10634, 14, 1018, 14, 5717, 14, 6767, 492, 334, 272, 17281, 2681, 2543, 12, 17281, 9641, 12, 272, 17281, 9205, 9, 199, 504, 10634, 14, 1018, 14, 5717, 14, 4752, 492, 440, 3540, 199, 504, 10634, 14, 1018, 492, 18036, 199, 504, 10634, 14, 5819, 492, 3482, 421, 199, 318, 485, 11636, 63, 2083, 63, 908, 63, 509, 63, 1144, 8, 5250, 12, 1011, 958, 304, 272, 327, 7649, 370, 9519, 314, 1475, 4079, 641, 314, 1642, 2222, 13, 14300, 1819, 272, 2222, 63, 4304, 63, 5527, 275, 440, 3540, 8, 5250, 680, 10262, 3430, 16, 61, 272, 340, 822, 8, 2865, 63, 4304, 63, 5527, 304, 267, 372, 485, 11636, 63, 2083, 63, 908, 8, 5250, 59, 2865, 63, 4304, 63, 5527, 59, 16, 2365, 1011, 958, 9, 421, 199, 318, 485, 11853, 63, 1637, 8, 1273, 12, 1475, 12, 2581, 12, 3957, 63, 513, 2930, 304, 272, 408, 272, 2790, 282, 2581, 402, 3747, 10831, 687, 376, 1625, 402, 10831, 339, 3897, 272, 4143, 272, 1680, 520, 3000, 12, 2069, 12, 1059, 12, 2197, 12, 769, 12, 2008, 12, 413, 13, 68, 1625, 12, 12403, 272, 1475, 520, 1059, 267, 8303, 5356, 1475, 370, 2198, 900, 272, 2581, 520, 5046, 267, 715, 12454, 370, 1218, 282, 2581, 402, 6702, 1338, 272, 3957, 63, 513, 2930, 520, 805, 267, 1448, 1023, 805, 370, 4838, 641, 10831, 339, 1803, 272, 5514, 272, 2581, 63, 1144, 520, 12403, 267, 11977, 402, 6702, 12, 3747, 10831, 14, 6855, 506, 2701, 272, 408, 272, 687, 10634, 492, 12403, 272, 2581, 63, 1144, 275, 12403, 342, 272, 340, 2581, 26, 267, 327, 14795, 282, 12530, 281, 3747, 1104, 267, 687, 10634, 492, 5499, 267, 340, 440, 5499, 8, 1273, 680, 374, 63, 3235, 26, 288, 3747, 63, 9356, 275, 18036, 14, 3235, 8, 1273, 9, 288, 2581, 63, 9356, 275, 3957, 63, 513, 2930, 8, 3235, 63, 9356, 12, 715, 12, 1475, 9, 288, 2581, 63, 1144, 275, 12403, 8, 1637, 63, 9356, 12, 1478, 29, 3235, 63, 9356, 9, 272, 372, 2581, 63, 1144, 421, 199, 318, 485, 3916, 63, 460, 63, 1977, 63, 1637, 8, 1273, 12, 2581, 63, 1144, 12, 5689, 12, 2552, 12, 536, 29, 403, 304, 272, 408, 272, 7905, 1625, 402, 10831, 543, 282, 2581, 436, 5689, 314, 754, 339, 3897, 272, 4143, 272, 1680, 520, 3000, 12, 2069, 12, 1059, 12, 2197, 12, 769, 12, 2008, 12, 413, 13, 68, 1625, 12, 12403, 272, 2581, 63, 1144, 520, 12403, 267, 11977, 402, 6702, 12, 3747, 10831, 272, 5689, 520, 5046, 267, 715, 17193, 754, 465, 376, 5499, 13, 2930, 12, 756, 2529, 376, 6800, 272, 2552, 520, 1059, 267, 283, 4247, 7, 12254, 5689, 29, 549, 911, 3957, 754, 370, 5499, 272, 536, 520, 1059, 12, 849, 488, 267, 2812, 367, 282, 29825, 2681, 339, 1803, 272, 5514, 272, 754, 520, 2197, 402, 6702, 10831, 267, 1803, 26, 398, 446, 5499, 13, 2930, 340, 5689, 29, 549, 267, 446, 6800, 340, 5689, 29, 797, 272, 408, 272, 687, 10634, 492, 12403, 12, 29825, 2681, 12, 5499, 272, 754, 275, 12403, 8, 1273, 680, 1130, 8, 1637, 63, 1144, 9, 272, 340, 5689, 26, 267, 340, 2552, 508, 283, 4247, 356, 288, 372, 5499, 8, 1099, 12, 536, 29, 354, 9, 267, 587, 26, 288, 372, 29825, 2681, 8, 1099, 12, 536, 29, 354, 9, 272, 372, 754, 14, 1459, 421, 199, 318, 485, 1107, 63, 6751, 63, 7145, 63, 2604, 8, 1099, 12, 7137, 83, 12, 5689, 12, 5823, 12, 536, 304, 272, 408, 272, 1432, 2058, 687, 1625, 63, 9866, 340, 282, 450, 90, 503, 450, 58, 13613, 1990, 3032, 14, 339, 3897, 272, 4143, 272, 754, 520, 6800, 267, 1109, 772, 1434, 30580, 402, 314, 10831, 272, 7137, 83, 520, 6800, 267, 15444, 7137, 2251, 272, 5689, 520, 5046, 267, 715, 17193, 754, 465, 376, 5499, 13, 2930, 12, 756, 2529, 376, 6800, 272, 5823, 520, 909, 267, 488, 503, 15444, 7137, 909, 272, 536, 520, 1059, 12, 849, 488, 267, 2812, 367, 282, 29825, 2681, 339, 1803, 272, 5514, 272, 5823, 63, 1099, 520, 6800, 402, 4565, 10831, 543, 7137, 267, 1803, 26, 398, 446, 5499, 13, 2930, 340, 5689, 29, 549, 267, 446, 6800, 402, 18267, 83, 340, 5689, 29, 797, 339, 408, 272, 340, 5823, 365, 440, 488, 26, 267, 746, 1722, 480, 6612, 986, 282, 5823, 1423, 1380, 298, 586, 298, 11059, 3326, 543, 7137, 298, 586, 298, 11697, 2685, 272, 5823, 63, 2604, 275, 980, 14, 1144, 779, 10239, 8, 470, 680, 3903, 63, 21279, 8, 2619, 9, 367, 522, 12, 5718, 2574, 315, 3482, 8, 1099, 12, 7137, 83, 3948, 272, 340, 5689, 26, 267, 687, 10634, 492, 5499, 267, 372, 5499, 8, 3903, 63, 2604, 12, 536, 29, 354, 9, 272, 372, 5823, 63, 2604, 421, 199, 318, 485, 3916, 63, 513, 2930, 63, 31601, 8, 1273, 12, 5689, 12, 1475, 12, 536, 29, 403, 12, 5823, 29, 403, 12, 1816, 4137, 29, 403, 12, 2552, 29, 403, 12 ]
[ 9143, 492, 7417, 199, 504, 2197, 492, 2197, 12, 900, 199, 504, 5055, 492, 29396, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 10634, 423, 8450, 492, 6714, 773, 12, 6714, 8450, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 9866, 492, 1625, 63, 9866, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 492, 6057, 12, 8603, 12, 18267, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 11059, 492, 334, 221, 327, 8151, 272, 2198, 63, 521, 63, 875, 12, 272, 6148, 9123, 12, 272, 485, 908, 63, 374, 63, 4595, 12, 272, 485, 11636, 63, 2083, 63, 908, 9, 199, 199, 504, 10634, 14, 1018, 14, 5717, 14, 2330, 492, 334, 272, 4868, 63, 785, 12, 272, 365, 63, 2083, 772, 63, 561, 63, 2271, 12, 272, 365, 63, 2083, 772, 63, 2271, 12, 272, 365, 63, 2083, 772, 3903, 63, 2271, 12, 272, 365, 63, 4115, 63, 2271, 12, 272, 365, 63, 4115, 12, 272, 365, 63, 1609, 12, 272, 365, 63, 513, 63, 2930, 12, 272, 365, 63, 7033, 12, 272, 365, 63, 6677, 63, 2271, 12, 272, 365, 63, 785, 63, 2271, 9, 199, 504, 10634, 14, 1018, 14, 5717, 14, 6767, 492, 334, 272, 17281, 2681, 2543, 12, 17281, 9641, 12, 272, 17281, 9205, 9, 199, 504, 10634, 14, 1018, 14, 5717, 14, 4752, 492, 440, 3540, 199, 504, 10634, 14, 1018, 492, 18036, 199, 504, 10634, 14, 5819, 492, 3482, 421, 199, 318, 485, 11636, 63, 2083, 63, 908, 63, 509, 63, 1144, 8, 5250, 12, 1011, 958, 304, 272, 327, 7649, 370, 9519, 314, 1475, 4079, 641, 314, 1642, 2222, 13, 14300, 1819, 272, 2222, 63, 4304, 63, 5527, 275, 440, 3540, 8, 5250, 680, 10262, 3430, 16, 61, 272, 340, 822, 8, 2865, 63, 4304, 63, 5527, 304, 267, 372, 485, 11636, 63, 2083, 63, 908, 8, 5250, 59, 2865, 63, 4304, 63, 5527, 59, 16, 2365, 1011, 958, 9, 421, 199, 318, 485, 11853, 63, 1637, 8, 1273, 12, 1475, 12, 2581, 12, 3957, 63, 513, 2930, 304, 272, 408, 272, 2790, 282, 2581, 402, 3747, 10831, 687, 376, 1625, 402, 10831, 339, 3897, 272, 4143, 272, 1680, 520, 3000, 12, 2069, 12, 1059, 12, 2197, 12, 769, 12, 2008, 12, 413, 13, 68, 1625, 12, 12403, 272, 1475, 520, 1059, 267, 8303, 5356, 1475, 370, 2198, 900, 272, 2581, 520, 5046, 267, 715, 12454, 370, 1218, 282, 2581, 402, 6702, 1338, 272, 3957, 63, 513, 2930, 520, 805, 267, 1448, 1023, 805, 370, 4838, 641, 10831, 339, 1803, 272, 5514, 272, 2581, 63, 1144, 520, 12403, 267, 11977, 402, 6702, 12, 3747, 10831, 14, 6855, 506, 2701, 272, 408, 272, 687, 10634, 492, 12403, 272, 2581, 63, 1144, 275, 12403, 342, 272, 340, 2581, 26, 267, 327, 14795, 282, 12530, 281, 3747, 1104, 267, 687, 10634, 492, 5499, 267, 340, 440, 5499, 8, 1273, 680, 374, 63, 3235, 26, 288, 3747, 63, 9356, 275, 18036, 14, 3235, 8, 1273, 9, 288, 2581, 63, 9356, 275, 3957, 63, 513, 2930, 8, 3235, 63, 9356, 12, 715, 12, 1475, 9, 288, 2581, 63, 1144, 275, 12403, 8, 1637, 63, 9356, 12, 1478, 29, 3235, 63, 9356, 9, 272, 372, 2581, 63, 1144, 421, 199, 318, 485, 3916, 63, 460, 63, 1977, 63, 1637, 8, 1273, 12, 2581, 63, 1144, 12, 5689, 12, 2552, 12, 536, 29, 403, 304, 272, 408, 272, 7905, 1625, 402, 10831, 543, 282, 2581, 436, 5689, 314, 754, 339, 3897, 272, 4143, 272, 1680, 520, 3000, 12, 2069, 12, 1059, 12, 2197, 12, 769, 12, 2008, 12, 413, 13, 68, 1625, 12, 12403, 272, 2581, 63, 1144, 520, 12403, 267, 11977, 402, 6702, 12, 3747, 10831, 272, 5689, 520, 5046, 267, 715, 17193, 754, 465, 376, 5499, 13, 2930, 12, 756, 2529, 376, 6800, 272, 2552, 520, 1059, 267, 283, 4247, 7, 12254, 5689, 29, 549, 911, 3957, 754, 370, 5499, 272, 536, 520, 1059, 12, 849, 488, 267, 2812, 367, 282, 29825, 2681, 339, 1803, 272, 5514, 272, 754, 520, 2197, 402, 6702, 10831, 267, 1803, 26, 398, 446, 5499, 13, 2930, 340, 5689, 29, 549, 267, 446, 6800, 340, 5689, 29, 797, 272, 408, 272, 687, 10634, 492, 12403, 12, 29825, 2681, 12, 5499, 272, 754, 275, 12403, 8, 1273, 680, 1130, 8, 1637, 63, 1144, 9, 272, 340, 5689, 26, 267, 340, 2552, 508, 283, 4247, 356, 288, 372, 5499, 8, 1099, 12, 536, 29, 354, 9, 267, 587, 26, 288, 372, 29825, 2681, 8, 1099, 12, 536, 29, 354, 9, 272, 372, 754, 14, 1459, 421, 199, 318, 485, 1107, 63, 6751, 63, 7145, 63, 2604, 8, 1099, 12, 7137, 83, 12, 5689, 12, 5823, 12, 536, 304, 272, 408, 272, 1432, 2058, 687, 1625, 63, 9866, 340, 282, 450, 90, 503, 450, 58, 13613, 1990, 3032, 14, 339, 3897, 272, 4143, 272, 754, 520, 6800, 267, 1109, 772, 1434, 30580, 402, 314, 10831, 272, 7137, 83, 520, 6800, 267, 15444, 7137, 2251, 272, 5689, 520, 5046, 267, 715, 17193, 754, 465, 376, 5499, 13, 2930, 12, 756, 2529, 376, 6800, 272, 5823, 520, 909, 267, 488, 503, 15444, 7137, 909, 272, 536, 520, 1059, 12, 849, 488, 267, 2812, 367, 282, 29825, 2681, 339, 1803, 272, 5514, 272, 5823, 63, 1099, 520, 6800, 402, 4565, 10831, 543, 7137, 267, 1803, 26, 398, 446, 5499, 13, 2930, 340, 5689, 29, 549, 267, 446, 6800, 402, 18267, 83, 340, 5689, 29, 797, 339, 408, 272, 340, 5823, 365, 440, 488, 26, 267, 746, 1722, 480, 6612, 986, 282, 5823, 1423, 1380, 298, 586, 298, 11059, 3326, 543, 7137, 298, 586, 298, 11697, 2685, 272, 5823, 63, 2604, 275, 980, 14, 1144, 779, 10239, 8, 470, 680, 3903, 63, 21279, 8, 2619, 9, 367, 522, 12, 5718, 2574, 315, 3482, 8, 1099, 12, 7137, 83, 3948, 272, 340, 5689, 26, 267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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
efortuna/AndroidSDKClone
ndk/prebuilt/linux-x86_64/lib/python2.7/encodings/iso2022_kr.py
816
1053
# # iso2022_kr.py: Python Unicode Codec for ISO2022_KR # # Written by Hye-Shik Chang <perky@FreeBSD.org> # import _codecs_iso2022, codecs import _multibytecodec as mbc codec = _codecs_iso2022.getcodec('iso2022_kr') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class IncrementalEncoder(mbc.MultibyteIncrementalEncoder, codecs.IncrementalEncoder): codec = codec class IncrementalDecoder(mbc.MultibyteIncrementalDecoder, codecs.IncrementalDecoder): codec = codec class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader): codec = codec class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter): codec = codec def getregentry(): return codecs.CodecInfo( name='iso2022_kr', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, )
apache-2.0
[ 3, 199, 3, 11601, 13859, 63, 16779, 14, 647, 26, 2018, 6140, 13732, 367, 9055, 13859, 63, 23063, 199, 3, 199, 3, 27694, 701, 869, 8048, 13, 2662, 3258, 2799, 621, 665, 529, 10562, 32, 10146, 15400, 14, 1308, 30, 199, 3, 199, 199, 646, 485, 8933, 63, 4595, 13859, 12, 6010, 199, 646, 485, 3029, 4414, 9276, 465, 333, 3776, 199, 199, 9276, 275, 485, 8933, 63, 4595, 13859, 14, 362, 9276, 360, 4595, 13859, 63, 16779, 358, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 272, 3752, 275, 9076, 14, 2143, 272, 4849, 275, 9076, 14, 2708, 199, 199, 533, 24350, 8, 887, 67, 14, 3947, 4414, 17016, 12, 586, 6010, 14, 17016, 304, 272, 9076, 275, 9076, 199, 199, 533, 24385, 8, 887, 67, 14, 3947, 4414, 16703, 12, 586, 6010, 14, 16703, 304, 272, 9076, 275, 9076, 199, 199, 533, 22970, 8, 8818, 12, 333, 3776, 14, 3947, 4414, 16132, 12, 6010, 14, 16132, 304, 272, 9076, 275, 9076, 199, 199, 533, 24163, 8, 8818, 12, 333, 3776, 14, 3947, 4414, 16551, 12, 6010, 14, 16551, 304, 272, 9076, 275, 9076, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 13859, 63, 16779, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 11601, 13859, 63, 16779, 14, 647, 26, 2018, 6140, 13732, 367, 9055, 13859, 63, 23063, 199, 3, 199, 3, 27694, 701, 869, 8048, 13, 2662, 3258, 2799, 621, 665, 529, 10562, 32, 10146, 15400, 14, 1308, 30, 199, 3, 199, 199, 646, 485, 8933, 63, 4595, 13859, 12, 6010, 199, 646, 485, 3029, 4414, 9276, 465, 333, 3776, 199, 199, 9276, 275, 485, 8933, 63, 4595, 13859, 14, 362, 9276, 360, 4595, 13859, 63, 16779, 358, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 272, 3752, 275, 9076, 14, 2143, 272, 4849, 275, 9076, 14, 2708, 199, 199, 533, 24350, 8, 887, 67, 14, 3947, 4414, 17016, 12, 586, 6010, 14, 17016, 304, 272, 9076, 275, 9076, 199, 199, 533, 24385, 8, 887, 67, 14, 3947, 4414, 16703, 12, 586, 6010, 14, 16703, 304, 272, 9076, 275, 9076, 199, 199, 533, 22970, 8, 8818, 12, 333, 3776, 14, 3947, 4414, 16132, 12, 6010, 14, 16132, 304, 272, 9076, 275, 9076, 199, 199, 533, 24163, 8, 8818, 12, 333, 3776, 14, 3947, 4414, 16551, 12, 6010, 14, 16551, 304, 272, 9076, 275, 9076, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 4595, 13859, 63, 16779, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Danielhiversen/home-assistant
homeassistant/components/light/mysensors.py
5
8122
""" Support for MySensors lights. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.mysensors/ """ from homeassistant.components import mysensors from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_HS_COLOR, ATTR_WHITE_VALUE, DOMAIN, SUPPORT_BRIGHTNESS, SUPPORT_COLOR, SUPPORT_WHITE_VALUE, Light) from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.util.color import rgb_hex_to_rgb_list import homeassistant.util.color as color_util SUPPORT_MYSENSORS_RGBW = SUPPORT_COLOR | SUPPORT_WHITE_VALUE async def async_setup_platform( hass, config, async_add_entities, discovery_info=None): """Set up the mysensors platform for lights.""" device_class_map = { 'S_DIMMER': MySensorsLightDimmer, 'S_RGB_LIGHT': MySensorsLightRGB, 'S_RGBW_LIGHT': MySensorsLightRGBW, } mysensors.setup_mysensors_platform( hass, DOMAIN, discovery_info, device_class_map, async_add_entities=async_add_entities) class MySensorsLight(mysensors.device.MySensorsEntity, Light): """Representation of a MySensors Light child node.""" def __init__(self, *args): """Initialize a MySensors Light.""" super().__init__(*args) self._state = None self._brightness = None self._hs = None self._white = None @property def brightness(self): """Return the brightness of this light between 0..255.""" return self._brightness @property def hs_color(self): """Return the hs color value [int, int].""" return self._hs @property def white_value(self): """Return the white value of this light between 0..255.""" return self._white @property def assumed_state(self): """Return true if unable to access real state of entity.""" return self.gateway.optimistic @property def is_on(self): """Return true if device is on.""" return self._state def _turn_on_light(self): """Turn on light child device.""" set_req = self.gateway.const.SetReq if self._state: return self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_LIGHT, 1) if self.gateway.optimistic: # optimistically assume that light has changed state self._state = True self._values[set_req.V_LIGHT] = STATE_ON def _turn_on_dimmer(self, **kwargs): """Turn on dimmer child device.""" set_req = self.gateway.const.SetReq brightness = self._brightness if ATTR_BRIGHTNESS not in kwargs or \ kwargs[ATTR_BRIGHTNESS] == self._brightness or \ set_req.V_DIMMER not in self._values: return brightness = kwargs[ATTR_BRIGHTNESS] percent = round(100 * brightness / 255) self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_DIMMER, percent) if self.gateway.optimistic: # optimistically assume that light has changed state self._brightness = brightness self._values[set_req.V_DIMMER] = percent def _turn_on_rgb_and_w(self, hex_template, **kwargs): """Turn on RGB or RGBW child device.""" rgb = list(color_util.color_hs_to_RGB(*self._hs)) white = self._white hex_color = self._values.get(self.value_type) hs_color = kwargs.get(ATTR_HS_COLOR) if hs_color is not None: new_rgb = color_util.color_hs_to_RGB(*hs_color) else: new_rgb = None new_white = kwargs.get(ATTR_WHITE_VALUE) if new_rgb is None and new_white is None: return if new_rgb is not None: rgb = list(new_rgb) if hex_template == '%02x%02x%02x%02x': if new_white is not None: rgb.append(new_white) else: rgb.append(white) hex_color = hex_template % tuple(rgb) if len(rgb) > 3: white = rgb.pop() self.gateway.set_child_value( self.node_id, self.child_id, self.value_type, hex_color) if self.gateway.optimistic: # optimistically assume that light has changed state self._hs = color_util.color_RGB_to_hs(*rgb) self._white = white self._values[self.value_type] = hex_color async def async_turn_off(self, **kwargs): """Turn the device off.""" value_type = self.gateway.const.SetReq.V_LIGHT self.gateway.set_child_value( self.node_id, self.child_id, value_type, 0) if self.gateway.optimistic: # optimistically assume that light has changed state self._state = False self._values[value_type] = STATE_OFF self.async_schedule_update_ha_state() def _async_update_light(self): """Update the controller with values from light child.""" value_type = self.gateway.const.SetReq.V_LIGHT self._state = self._values[value_type] == STATE_ON def _async_update_dimmer(self): """Update the controller with values from dimmer child.""" value_type = self.gateway.const.SetReq.V_DIMMER if value_type in self._values: self._brightness = round(255 * int(self._values[value_type]) / 100) if self._brightness == 0: self._state = False def _async_update_rgb_or_w(self): """Update the controller with values from RGB or RGBW child.""" value = self._values[self.value_type] color_list = rgb_hex_to_rgb_list(value) if len(color_list) > 3: self._white = color_list.pop() self._hs = color_util.color_RGB_to_hs(*color_list) class MySensorsLightDimmer(MySensorsLight): """Dimmer child class to MySensorsLight.""" @property def supported_features(self): """Flag supported features.""" return SUPPORT_BRIGHTNESS async def async_turn_on(self, **kwargs): """Turn the device on.""" self._turn_on_light() self._turn_on_dimmer(**kwargs) if self.gateway.optimistic: self.async_schedule_update_ha_state() async def async_update(self): """Update the controller with the latest value from a sensor.""" await super().async_update() self._async_update_light() self._async_update_dimmer() class MySensorsLightRGB(MySensorsLight): """RGB child class to MySensorsLight.""" @property def supported_features(self): """Flag supported features.""" set_req = self.gateway.const.SetReq if set_req.V_DIMMER in self._values: return SUPPORT_BRIGHTNESS | SUPPORT_COLOR return SUPPORT_COLOR async def async_turn_on(self, **kwargs): """Turn the device on.""" self._turn_on_light() self._turn_on_dimmer(**kwargs) self._turn_on_rgb_and_w('%02x%02x%02x', **kwargs) if self.gateway.optimistic: self.async_schedule_update_ha_state() async def async_update(self): """Update the controller with the latest value from a sensor.""" await super().async_update() self._async_update_light() self._async_update_dimmer() self._async_update_rgb_or_w() class MySensorsLightRGBW(MySensorsLightRGB): """RGBW child class to MySensorsLightRGB.""" # pylint: disable=too-many-ancestors @property def supported_features(self): """Flag supported features.""" set_req = self.gateway.const.SetReq if set_req.V_DIMMER in self._values: return SUPPORT_BRIGHTNESS | SUPPORT_MYSENSORS_RGBW return SUPPORT_MYSENSORS_RGBW async def async_turn_on(self, **kwargs): """Turn the device on.""" self._turn_on_light() self._turn_on_dimmer(**kwargs) self._turn_on_rgb_and_w('%02x%02x%02x%02x', **kwargs) if self.gateway.optimistic: self.async_schedule_update_ha_state()
mit
[ 624, 199, 11532, 367, 4932, 51, 17564, 10540, 83, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 4040, 14, 1662, 22675, 15, 199, 624, 199, 504, 8846, 14, 4608, 492, 3002, 22675, 199, 504, 8846, 14, 4608, 14, 4040, 492, 334, 272, 10762, 63, 30976, 3025, 12, 10762, 63, 15467, 63, 7134, 12, 10762, 63, 18817, 63, 7041, 12, 15265, 12, 272, 13756, 63, 30976, 3025, 12, 13756, 63, 7134, 12, 13756, 63, 18817, 63, 7041, 12, 29684, 9, 199, 504, 8846, 14, 1297, 492, 11377, 63, 7517, 12, 11377, 63, 615, 199, 504, 8846, 14, 1974, 14, 2326, 492, 15180, 63, 4097, 63, 475, 63, 10090, 63, 513, 199, 646, 8846, 14, 1974, 14, 2326, 465, 3164, 63, 1974, 199, 199, 10640, 63, 12339, 51, 8456, 4149, 63, 12067, 55, 275, 13756, 63, 7134, 1204, 13756, 63, 18817, 63, 7041, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 267, 6298, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 3002, 22675, 4298, 367, 10540, 83, 1041, 272, 2243, 63, 533, 63, 1130, 275, 469, 267, 283, 51, 63, 19080, 20263, 356, 4932, 51, 17564, 16393, 19156, 2626, 12, 267, 283, 51, 63, 12067, 63, 21613, 356, 4932, 51, 17564, 16393, 12067, 12, 267, 283, 51, 63, 12067, 55, 63, 21613, 356, 4932, 51, 17564, 16393, 12067, 55, 12, 272, 789, 272, 3002, 22675, 14, 2758, 63, 1662, 22675, 63, 3246, 8, 267, 6298, 12, 15265, 12, 13172, 63, 815, 12, 2243, 63, 533, 63, 1130, 12, 267, 5316, 63, 525, 63, 8327, 29, 4146, 63, 525, 63, 8327, 9, 421, 199, 533, 4932, 51, 17564, 16393, 8, 1662, 22675, 14, 1782, 14, 5713, 51, 17564, 7302, 12, 29684, 304, 272, 408, 20609, 402, 282, 4932, 51, 17564, 29684, 1982, 1031, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 408, 9345, 282, 4932, 51, 17564, 29684, 1041, 267, 1613, 11027, 826, 9308, 589, 9, 267, 291, 423, 929, 275, 488, 267, 291, 423, 22298, 275, 488, 267, 291, 423, 4213, 275, 488, 267, 291, 423, 7510, 275, 488, 339, 768, 1829, 272, 347, 27702, 8, 277, 304, 267, 408, 1767, 314, 27702, 402, 642, 10540, 3382, 378, 703, 2299, 1041, 267, 372, 291, 423, 22298, 339, 768, 1829, 272, 347, 17446, 63, 2326, 8, 277, 304, 267, 408, 1767, 314, 17446, 3164, 574, 359, 442, 12, 1109, 61, 1041, 267, 372, 291, 423, 4213, 339, 768, 1829, 272, 347, 10424, 63, 585, 8, 277, 304, 267, 408, 1767, 314, 10424, 574, 402, 642, 10540, 3382, 378, 703, 2299, 1041, 267, 372, 291, 423, 7510, 339, 768, 1829, 272, 347, 10826, 63, 929, 8, 277, 304, 267, 408, 1767, 2549, 340, 17329, 370, 2879, 3363, 1174, 402, 4642, 1041, 267, 372, 291, 14, 7019, 14, 6433, 6937, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 347, 485, 353, 63, 265, 63, 4040, 8, 277, 304, 267, 408, 16838, 641, 10540, 1982, 2243, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 398, 340, 291, 423, 929, 26, 288, 372, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 21613, 12, 413, 9, 398, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 5323, 6937, 1183, 5534, 626, 10540, 965, 2896, 1174, 288, 291, 423, 929, 275, 715, 288, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 21613, 61, 275, 11377, 63, 615, 339, 347, 485, 353, 63, 265, 63, 3572, 2626, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 641, 8134, 2626, 1982, 2243, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 27702, 275, 291, 423, 22298, 398, 340, 10762, 63, 30976, 3025, 440, 315, 2074, 503, 971, 355, 2074, 59, 5280, 63, 30976, 3025, 61, 508, 291, 423, 22298, 503, 971, 355, 663, 63, 2103, 14, 54, 63, 19080, 20263, 440, 315, 291, 423, 1459, 26, 288, 372, 267, 27702, 275, 2074, 59, 5280, 63, 30976, 3025, 61, 267, 8878, 275, 6168, 8, 1960, 627, 27702, 1182, 5450, 9, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 19080, 20263, 12, 8878, 9, 398, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 5323, 6937, 1183, 5534, 626, 10540, 965, 2896, 1174, 288, 291, 423, 22298, 275, 27702, 288, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 8878, 339, 347, 485, 353, 63, 265, 63, 10090, 63, 460, 63, 87, 8, 277, 12, 6318, 63, 1160, 12, 1011, 958, 304, 267, 408, 16838, 641, 19013, 503, 19013, 55, 1982, 2243, 1041, 267, 15180, 275, 769, 8, 2326, 63, 1974, 14, 2326, 63, 4213, 63, 475, 63, 12067, 2031, 277, 423, 4213, 430, 267, 10424, 275, 291, 423, 7510, 267, 6318, 63, 2326, 275, 291, 423, 1459, 14, 362, 8, 277, 14, 585, 63, 466, 9, 267, 17446, 63, 2326, 275, 2074, 14, 362, 8, 5280, 63, 15467, 63, 7134, 9, 267, 340, 17446, 63, 2326, 365, 440, 488, 26, 288, 892, 63, 10090, 275, 3164, 63, 1974, 14, 2326, 63, 4213, 63, 475, 63, 12067, 2031, 4213, 63, 2326, 9, 267, 587, 26, 288, 892, 63, 10090, 275, 488, 267, 892, 63, 7510, 275, 2074, 14, 362, 8, 5280, 63, 18817, 63, 7041, 9, 398, 340, 892, 63, 10090, 365, 488, 436, 892, 63, 7510, 365, 488, 26, 288, 372, 267, 340, 892, 63, 10090, 365, 440, 488, 26, 288, 15180, 275, 769, 8, 1222, 63, 10090, 9, 267, 340, 6318, 63, 1160, 508, 1543, 996, 88, 5, 996, 88, 5, 996, 88, 5, 996, 88, 356, 288, 340, 892, 63, 7510, 365, 440, 488 ]
[ 199, 11532, 367, 4932, 51, 17564, 10540, 83, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 4040, 14, 1662, 22675, 15, 199, 624, 199, 504, 8846, 14, 4608, 492, 3002, 22675, 199, 504, 8846, 14, 4608, 14, 4040, 492, 334, 272, 10762, 63, 30976, 3025, 12, 10762, 63, 15467, 63, 7134, 12, 10762, 63, 18817, 63, 7041, 12, 15265, 12, 272, 13756, 63, 30976, 3025, 12, 13756, 63, 7134, 12, 13756, 63, 18817, 63, 7041, 12, 29684, 9, 199, 504, 8846, 14, 1297, 492, 11377, 63, 7517, 12, 11377, 63, 615, 199, 504, 8846, 14, 1974, 14, 2326, 492, 15180, 63, 4097, 63, 475, 63, 10090, 63, 513, 199, 646, 8846, 14, 1974, 14, 2326, 465, 3164, 63, 1974, 199, 199, 10640, 63, 12339, 51, 8456, 4149, 63, 12067, 55, 275, 13756, 63, 7134, 1204, 13756, 63, 18817, 63, 7041, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 267, 6298, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 3002, 22675, 4298, 367, 10540, 83, 1041, 272, 2243, 63, 533, 63, 1130, 275, 469, 267, 283, 51, 63, 19080, 20263, 356, 4932, 51, 17564, 16393, 19156, 2626, 12, 267, 283, 51, 63, 12067, 63, 21613, 356, 4932, 51, 17564, 16393, 12067, 12, 267, 283, 51, 63, 12067, 55, 63, 21613, 356, 4932, 51, 17564, 16393, 12067, 55, 12, 272, 789, 272, 3002, 22675, 14, 2758, 63, 1662, 22675, 63, 3246, 8, 267, 6298, 12, 15265, 12, 13172, 63, 815, 12, 2243, 63, 533, 63, 1130, 12, 267, 5316, 63, 525, 63, 8327, 29, 4146, 63, 525, 63, 8327, 9, 421, 199, 533, 4932, 51, 17564, 16393, 8, 1662, 22675, 14, 1782, 14, 5713, 51, 17564, 7302, 12, 29684, 304, 272, 408, 20609, 402, 282, 4932, 51, 17564, 29684, 1982, 1031, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 408, 9345, 282, 4932, 51, 17564, 29684, 1041, 267, 1613, 11027, 826, 9308, 589, 9, 267, 291, 423, 929, 275, 488, 267, 291, 423, 22298, 275, 488, 267, 291, 423, 4213, 275, 488, 267, 291, 423, 7510, 275, 488, 339, 768, 1829, 272, 347, 27702, 8, 277, 304, 267, 408, 1767, 314, 27702, 402, 642, 10540, 3382, 378, 703, 2299, 1041, 267, 372, 291, 423, 22298, 339, 768, 1829, 272, 347, 17446, 63, 2326, 8, 277, 304, 267, 408, 1767, 314, 17446, 3164, 574, 359, 442, 12, 1109, 61, 1041, 267, 372, 291, 423, 4213, 339, 768, 1829, 272, 347, 10424, 63, 585, 8, 277, 304, 267, 408, 1767, 314, 10424, 574, 402, 642, 10540, 3382, 378, 703, 2299, 1041, 267, 372, 291, 423, 7510, 339, 768, 1829, 272, 347, 10826, 63, 929, 8, 277, 304, 267, 408, 1767, 2549, 340, 17329, 370, 2879, 3363, 1174, 402, 4642, 1041, 267, 372, 291, 14, 7019, 14, 6433, 6937, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 2243, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 347, 485, 353, 63, 265, 63, 4040, 8, 277, 304, 267, 408, 16838, 641, 10540, 1982, 2243, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 398, 340, 291, 423, 929, 26, 288, 372, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 21613, 12, 413, 9, 398, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 5323, 6937, 1183, 5534, 626, 10540, 965, 2896, 1174, 288, 291, 423, 929, 275, 715, 288, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 21613, 61, 275, 11377, 63, 615, 339, 347, 485, 353, 63, 265, 63, 3572, 2626, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 641, 8134, 2626, 1982, 2243, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 27702, 275, 291, 423, 22298, 398, 340, 10762, 63, 30976, 3025, 440, 315, 2074, 503, 971, 355, 2074, 59, 5280, 63, 30976, 3025, 61, 508, 291, 423, 22298, 503, 971, 355, 663, 63, 2103, 14, 54, 63, 19080, 20263, 440, 315, 291, 423, 1459, 26, 288, 372, 267, 27702, 275, 2074, 59, 5280, 63, 30976, 3025, 61, 267, 8878, 275, 6168, 8, 1960, 627, 27702, 1182, 5450, 9, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 19080, 20263, 12, 8878, 9, 398, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 5323, 6937, 1183, 5534, 626, 10540, 965, 2896, 1174, 288, 291, 423, 22298, 275, 27702, 288, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 8878, 339, 347, 485, 353, 63, 265, 63, 10090, 63, 460, 63, 87, 8, 277, 12, 6318, 63, 1160, 12, 1011, 958, 304, 267, 408, 16838, 641, 19013, 503, 19013, 55, 1982, 2243, 1041, 267, 15180, 275, 769, 8, 2326, 63, 1974, 14, 2326, 63, 4213, 63, 475, 63, 12067, 2031, 277, 423, 4213, 430, 267, 10424, 275, 291, 423, 7510, 267, 6318, 63, 2326, 275, 291, 423, 1459, 14, 362, 8, 277, 14, 585, 63, 466, 9, 267, 17446, 63, 2326, 275, 2074, 14, 362, 8, 5280, 63, 15467, 63, 7134, 9, 267, 340, 17446, 63, 2326, 365, 440, 488, 26, 288, 892, 63, 10090, 275, 3164, 63, 1974, 14, 2326, 63, 4213, 63, 475, 63, 12067, 2031, 4213, 63, 2326, 9, 267, 587, 26, 288, 892, 63, 10090, 275, 488, 267, 892, 63, 7510, 275, 2074, 14, 362, 8, 5280, 63, 18817, 63, 7041, 9, 398, 340, 892, 63, 10090, 365, 488, 436, 892, 63, 7510, 365, 488, 26, 288, 372, 267, 340, 892, 63, 10090, 365, 440, 488, 26, 288, 15180, 275, 769, 8, 1222, 63, 10090, 9, 267, 340, 6318, 63, 1160, 508, 1543, 996, 88, 5, 996, 88, 5, 996, 88, 5, 996, 88, 356, 288, 340, 892, 63, 7510, 365, 440, 488, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aaron-goshine/electron
script/lib/config.py
14
1517
#!/usr/bin/env python import errno import os import platform import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'http://github-janky-artifacts.s3.amazonaws.com/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = '04523758cda2a96d2454f9056fb1fb9a1c1f95f1' PLATFORM = { 'cygwin': 'win32', 'darwin': 'darwin', 'linux2': 'linux', 'win32': 'win32', }[sys.platform] verbose_mode = False def get_target_arch(): try: target_arch_path = os.path.join(__file__, '..', '..', '..', 'vendor', 'brightray', 'vendor', 'download', 'libchromiumcontent', '.target_arch') with open(os.path.normpath(target_arch_path)) as f: return f.read().strip() except IOError as e: if e.errno != errno.ENOENT: raise if PLATFORM == 'win32': return 'ia32' else: return 'x64' def get_chromedriver_version(): return 'v2.15' def s3_config(): config = (os.environ.get('ATOM_SHELL_S3_BUCKET', ''), os.environ.get('ATOM_SHELL_S3_ACCESS_KEY', ''), os.environ.get('ATOM_SHELL_S3_SECRET_KEY', '')) message = ('Error: Please set the $ATOM_SHELL_S3_BUCKET, ' '$ATOM_SHELL_S3_ACCESS_KEY, and ' '$ATOM_SHELL_S3_SECRET_KEY environment variables') assert all(len(c) for c in config), message return config def enable_verbose_mode(): print 'Running in verbose mode' global verbose_mode verbose_mode = True def is_verbose_mode(): return verbose_mode
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 4298, 199, 646, 984, 421, 199, 5825, 63, 2632, 275, 747, 14, 12959, 360, 5617, 30334, 24967, 9663, 63, 45, 3927, 50, 726, 358, 503, 971, 272, 283, 1014, 921, 5031, 13, 74, 3580, 89, 13, 30129, 14, 83, 19, 14, 21442, 14, 957, 15, 773, 13211, 1317, 7, 199, 5617, 30334, 24967, 9663, 63, 23446, 275, 283, 966, 2528, 1401, 2010, 67, 983, 18, 65, 2534, 68, 1194, 1477, 70, 2710, 1367, 4675, 17, 4675, 25, 65, 17, 67, 17, 70, 2720, 70, 17, 7, 199, 199, 17805, 275, 469, 523, 283, 16680, 356, 283, 2676, 708, 297, 523, 283, 13245, 356, 283, 13245, 297, 523, 283, 5135, 18, 356, 283, 5135, 297, 523, 283, 2676, 708, 356, 283, 2676, 708, 297, 199, 22857, 1274, 14, 3246, 61, 199, 199, 3832, 63, 632, 275, 756, 421, 199, 318, 664, 63, 1375, 63, 1047, 837, 523, 862, 26, 272, 1347, 63, 1047, 63, 515, 275, 747, 14, 515, 14, 904, 3460, 493, 3108, 19155, 19155, 19155, 283, 9884, 297, 2511, 283, 27454, 803, 297, 283, 9884, 297, 283, 4249, 297, 2511, 283, 773, 13211, 1317, 297, 1987, 1375, 63, 1047, 358, 272, 543, 1551, 8, 736, 14, 515, 14, 9267, 8, 1375, 63, 1047, 63, 515, 430, 465, 289, 26, 489, 372, 289, 14, 739, 1252, 1913, 342, 523, 871, 5925, 465, 325, 26, 272, 340, 325, 14, 7931, 1137, 7554, 14, 20465, 26, 489, 746, 819, 340, 21966, 508, 283, 2676, 708, 356, 272, 372, 283, 4674, 708, 7, 523, 587, 26, 272, 372, 283, 88, 772, 7, 421, 199, 318, 664, 63, 9887, 3090, 63, 1023, 837, 523, 372, 283, 86, 18, 14, 1046, 7, 421, 199, 318, 308, 19, 63, 888, 837, 523, 1101, 275, 334, 736, 14, 2314, 14, 362, 360, 22479, 63, 29085, 63, 51, 19, 63, 20156, 297, 9929, 288, 747, 14, 2314, 14, 362, 360, 22479, 63, 29085, 63, 51, 19, 63, 11074, 63, 3078, 297, 9929, 288, 747, 14, 2314, 14, 362, 360, 22479, 63, 29085, 63, 51, 19, 63, 12961, 63, 3078, 297, 12381, 523, 1245, 275, 661, 547, 26, 7754, 663, 314, 2672, 22479, 63, 29085, 63, 51, 19, 63, 20156, 12, 283, 1467, 4505, 22479, 63, 29085, 63, 51, 19, 63, 11074, 63, 3078, 12, 436, 283, 1467, 4505, 22479, 63, 29085, 63, 51, 19, 63, 12961, 63, 3078, 3734, 2860, 358, 523, 702, 1006, 8, 552, 8, 67, 9, 367, 286, 315, 1101, 395, 1245, 523, 372, 1101, 421, 199, 318, 4756, 63, 3832, 63, 632, 837, 523, 870, 283, 9602, 315, 3376, 818, 7, 523, 2288, 3376, 63, 632, 523, 3376, 63, 632, 275, 715, 421, 199, 318, 365, 63, 3832, 63, 632, 837, 523, 372, 3376, 63, 632, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 4298, 199, 646, 984, 421, 199, 5825, 63, 2632, 275, 747, 14, 12959, 360, 5617, 30334, 24967, 9663, 63, 45, 3927, 50, 726, 358, 503, 971, 272, 283, 1014, 921, 5031, 13, 74, 3580, 89, 13, 30129, 14, 83, 19, 14, 21442, 14, 957, 15, 773, 13211, 1317, 7, 199, 5617, 30334, 24967, 9663, 63, 23446, 275, 283, 966, 2528, 1401, 2010, 67, 983, 18, 65, 2534, 68, 1194, 1477, 70, 2710, 1367, 4675, 17, 4675, 25, 65, 17, 67, 17, 70, 2720, 70, 17, 7, 199, 199, 17805, 275, 469, 523, 283, 16680, 356, 283, 2676, 708, 297, 523, 283, 13245, 356, 283, 13245, 297, 523, 283, 5135, 18, 356, 283, 5135, 297, 523, 283, 2676, 708, 356, 283, 2676, 708, 297, 199, 22857, 1274, 14, 3246, 61, 199, 199, 3832, 63, 632, 275, 756, 421, 199, 318, 664, 63, 1375, 63, 1047, 837, 523, 862, 26, 272, 1347, 63, 1047, 63, 515, 275, 747, 14, 515, 14, 904, 3460, 493, 3108, 19155, 19155, 19155, 283, 9884, 297, 2511, 283, 27454, 803, 297, 283, 9884, 297, 283, 4249, 297, 2511, 283, 773, 13211, 1317, 297, 1987, 1375, 63, 1047, 358, 272, 543, 1551, 8, 736, 14, 515, 14, 9267, 8, 1375, 63, 1047, 63, 515, 430, 465, 289, 26, 489, 372, 289, 14, 739, 1252, 1913, 342, 523, 871, 5925, 465, 325, 26, 272, 340, 325, 14, 7931, 1137, 7554, 14, 20465, 26, 489, 746, 819, 340, 21966, 508, 283, 2676, 708, 356, 272, 372, 283, 4674, 708, 7, 523, 587, 26, 272, 372, 283, 88, 772, 7, 421, 199, 318, 664, 63, 9887, 3090, 63, 1023, 837, 523, 372, 283, 86, 18, 14, 1046, 7, 421, 199, 318, 308, 19, 63, 888, 837, 523, 1101, 275, 334, 736, 14, 2314, 14, 362, 360, 22479, 63, 29085, 63, 51, 19, 63, 20156, 297, 9929, 288, 747, 14, 2314, 14, 362, 360, 22479, 63, 29085, 63, 51, 19, 63, 11074, 63, 3078, 297, 9929, 288, 747, 14, 2314, 14, 362, 360, 22479, 63, 29085, 63, 51, 19, 63, 12961, 63, 3078, 297, 12381, 523, 1245, 275, 661, 547, 26, 7754, 663, 314, 2672, 22479, 63, 29085, 63, 51, 19, 63, 20156, 12, 283, 1467, 4505, 22479, 63, 29085, 63, 51, 19, 63, 11074, 63, 3078, 12, 436, 283, 1467, 4505, 22479, 63, 29085, 63, 51, 19, 63, 12961, 63, 3078, 3734, 2860, 358, 523, 702, 1006, 8, 552, 8, 67, 9, 367, 286, 315, 1101, 395, 1245, 523, 372, 1101, 421, 199, 318, 4756, 63, 3832, 63, 632, 837, 523, 870, 283, 9602, 315, 3376, 818, 7, 523, 2288, 3376, 63, 632, 523, 3376, 63, 632, 275, 715, 421, 199, 318, 365, 63, 3832, 63, 632, 837, 523, 372, 3376, 63, 632, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wujuguang/wrapt
src/decorators.py
19
20139
"""This module implements decorators for implementing other decorators as well as some commonly used decorators. """ import sys PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 if PY3: string_types = str, import builtins exec_ = getattr(builtins, "exec") del builtins else: string_types = basestring, def exec_(_code_, _globs_=None, _locs_=None): """Execute code in a namespace.""" if _globs_ is None: frame = sys._getframe(1) _globs_ = frame.f_globals if _locs_ is None: _locs_ = frame.f_locals del frame elif _locs_ is None: _locs_ = _globs_ exec("""exec _code_ in _globs_, _locs_""") from functools import partial from inspect import getargspec, ismethod, isclass, formatargspec from collections import namedtuple from threading import Lock, RLock try: from inspect import signature except ImportError: pass from .wrappers import (FunctionWrapper, BoundFunctionWrapper, ObjectProxy, CallableObjectProxy) # Adapter wrapper for the wrapped function which will overlay certain # properties from the adapter function onto the wrapped function so that # functions such as inspect.getargspec(), inspect.getfullargspec(), # inspect.signature() and inspect.getsource() return the correct results # one would expect. class _AdapterFunctionCode(CallableObjectProxy): def __init__(self, wrapped_code, adapter_code): super(_AdapterFunctionCode, self).__init__(wrapped_code) self._self_adapter_code = adapter_code @property def co_argcount(self): return self._self_adapter_code.co_argcount @property def co_code(self): return self._self_adapter_code.co_code @property def co_flags(self): return self._self_adapter_code.co_flags @property def co_kwonlyargcount(self): return self._self_adapter_code.co_kwonlyargcount @property def co_varnames(self): return self._self_adapter_code.co_varnames class _AdapterFunctionSurrogate(CallableObjectProxy): def __init__(self, wrapped, adapter): super(_AdapterFunctionSurrogate, self).__init__(wrapped) self._self_adapter = adapter @property def __code__(self): return _AdapterFunctionCode(self.__wrapped__.__code__, self._self_adapter.__code__) @property def __defaults__(self): return self._self_adapter.__defaults__ @property def __kwdefaults__(self): return self._self_adapter.__kwdefaults__ @property def __signature__(self): if 'signature' not in globals(): return self._self_adapter.__signature__ else: # Can't allow this to fail on Python 3 else it falls # through to using __wrapped__, but that will be the # wrong function we want to derive the signature # from. Thus generate the signature ourselves. return signature(self._self_adapter) if PY2: func_code = __code__ func_defaults = __defaults__ class _BoundAdapterWrapper(BoundFunctionWrapper): @property def __func__(self): return _AdapterFunctionSurrogate(self.__wrapped__.__func__, self._self_parent._self_adapter) if PY2: im_func = __func__ class AdapterWrapper(FunctionWrapper): __bound_function_wrapper__ = _BoundAdapterWrapper def __init__(self, *args, **kwargs): adapter = kwargs.pop('adapter') super(AdapterWrapper, self).__init__(*args, **kwargs) self._self_surrogate = _AdapterFunctionSurrogate( self.__wrapped__, adapter) self._self_adapter = adapter @property def __code__(self): return self._self_surrogate.__code__ @property def __defaults__(self): return self._self_surrogate.__defaults__ @property def __kwdefaults__(self): return self._self_surrogate.__kwdefaults__ if PY2: func_code = __code__ func_defaults = __defaults__ @property def __signature__(self): return self._self_surrogate.__signature__ class AdapterFactory(object): def __call__(self, wrapped): raise NotImplementedError() class DelegatedAdapterFactory(AdapterFactory): def __init__(self, factory): super(DelegatedAdapterFactory, self).__init__() self.factory = factory def __call__(self, wrapped): return self.factory(wrapped) adapter_factory = DelegatedAdapterFactory # Decorator for creating other decorators. This decorator and the # wrappers which they use are designed to properly preserve any name # attributes, function signatures etc, in addition to the wrappers # themselves acting like a transparent proxy for the original wrapped # function so the wrapper is effectively indistinguishable from the # original wrapped function. def decorator(wrapper=None, enabled=None, adapter=None): # The decorator should be supplied with a single positional argument # which is the wrapper function to be used to implement the # decorator. This may be preceded by a step whereby the keyword # arguments are supplied to customise the behaviour of the # decorator. The 'adapter' argument is used to optionally denote a # separate function which is notionally used by an adapter # decorator. In that case parts of the function '__code__' and # '__defaults__' attributes are used from the adapter function # rather than those of the wrapped function. This allows for the # argument specification from inspect.getargspec() to be overridden # with a prototype for a different function than what was wrapped. # The 'enabled' argument provides a way to enable/disable the use # of the decorator. If the type of 'enabled' is a boolean, then it # is evaluated immediately and the wrapper not even applied if # it is False. If not a boolean, it will be evaluated when the # wrapper is called for an unbound wrapper, and when binding occurs # for a bound wrapper. When being evaluated, if 'enabled' is callable # it will be called to obtain the value to be checked. If False, # the wrapper will not be called and instead the original wrapped # function will be called directly instead. if wrapper is not None: # Helper function for creating wrapper of the appropriate # time when we need it down below. def _build(wrapped, wrapper, enabled=None, adapter=None): if adapter: if isinstance(adapter, AdapterFactory): adapter = adapter(wrapped) if not callable(adapter): ns = {} if not isinstance(adapter, string_types): adapter = formatargspec(*adapter) exec_('def adapter{0}: pass'.format(adapter), ns, ns) adapter = ns['adapter'] return AdapterWrapper(wrapped=wrapped, wrapper=wrapper, enabled=enabled, adapter=adapter) return FunctionWrapper(wrapped=wrapped, wrapper=wrapper, enabled=enabled) # The wrapper has been provided so return the final decorator. # The decorator is itself one of our function wrappers so we # can determine when it is applied to functions, instance methods # or class methods. This allows us to bind the instance or class # method so the appropriate self or cls attribute is supplied # when it is finally called. def _wrapper(wrapped, instance, args, kwargs): # We first check for the case where the decorator was applied # to a class type. # # @decorator # class mydecoratorclass(object): # def __init__(self, arg=None): # self.arg = arg # def __call__(self, wrapped, instance, args, kwargs): # return wrapped(*args, **kwargs) # # @mydecoratorclass(arg=1) # def function(): # pass # # In this case an instance of the class is to be used as the # decorator wrapper function. If args was empty at this point, # then it means that there were optional keyword arguments # supplied to be used when creating an instance of the class # to be used as the wrapper function. if instance is None and isclass(wrapped) and not args: # We still need to be passed the target function to be # wrapped as yet, so we need to return a further function # to be able to capture it. def _capture(target_wrapped): # Now have the target function to be wrapped and need # to create an instance of the class which is to act # as the decorator wrapper function. Before we do that, # we need to first check that use of the decorator # hadn't been disabled by a simple boolean. If it was, # the target function to be wrapped is returned instead. _enabled = enabled if type(_enabled) is bool: if not _enabled: return target_wrapped _enabled = None # Now create an instance of the class which is to act # as the decorator wrapper function. Any arguments had # to be supplied as keyword only arguments so that is # all we pass when creating it. target_wrapper = wrapped(**kwargs) # Finally build the wrapper itself and return it. return _build(target_wrapped, target_wrapper, _enabled, adapter) return _capture # We should always have the target function to be wrapped at # this point as the first (and only) value in args. target_wrapped = args[0] # Need to now check that use of the decorator hadn't been # disabled by a simple boolean. If it was, then target # function to be wrapped is returned instead. _enabled = enabled if type(_enabled) is bool: if not _enabled: return target_wrapped _enabled = None # We now need to build the wrapper, but there are a couple of # different cases we need to consider. if instance is None: if isclass(wrapped): # In this case the decorator was applied to a class # type but optional keyword arguments were not supplied # for initialising an instance of the class to be used # as the decorator wrapper function. # # @decorator # class mydecoratorclass(object): # def __init__(self, arg=None): # self.arg = arg # def __call__(self, wrapped, instance, # args, kwargs): # return wrapped(*args, **kwargs) # # @mydecoratorclass # def function(): # pass # # We still need to create an instance of the class to # be used as the decorator wrapper function, but no # arguments are pass. target_wrapper = wrapped() else: # In this case the decorator was applied to a normal # function, or possibly a static method of a class. # # @decorator # def mydecoratorfuntion(wrapped, instance, # args, kwargs): # return wrapped(*args, **kwargs) # # @mydecoratorfunction # def function(): # pass # # That normal function becomes the decorator wrapper # function. target_wrapper = wrapper else: if isclass(instance): # In this case the decorator was applied to a class # method. # # class myclass(object): # @decorator # @classmethod # def decoratorclassmethod(cls, wrapped, # instance, args, kwargs): # return wrapped(*args, **kwargs) # # instance = myclass() # # @instance.decoratorclassmethod # def function(): # pass # # This one is a bit strange because binding was actually # performed on the wrapper created by our decorator # factory. We need to apply that binding to the decorator # wrapper function which which the decorator factory # was applied to. target_wrapper = wrapper.__get__(None, instance) else: # In this case the decorator was applied to an instance # method. # # class myclass(object): # @decorator # def decoratorclassmethod(self, wrapped, # instance, args, kwargs): # return wrapped(*args, **kwargs) # # instance = myclass() # # @instance.decoratorclassmethod # def function(): # pass # # This one is a bit strange because binding was actually # performed on the wrapper created by our decorator # factory. We need to apply that binding to the decorator # wrapper function which which the decorator factory # was applied to. target_wrapper = wrapper.__get__(instance, type(instance)) # Finally build the wrapper itself and return it. return _build(target_wrapped, target_wrapper, _enabled, adapter) # We first return our magic function wrapper here so we can # determine in what context the decorator factory was used. In # other words, it is itself a universal decorator. return _build(wrapper, _wrapper) else: # The wrapper still has not been provided, so we are just # collecting the optional keyword arguments. Return the # decorator again wrapped in a partial using the collected # arguments. return partial(decorator, enabled=enabled, adapter=adapter) # Decorator for implementing thread synchronization. It can be used as a # decorator, in which case the synchronization context is determined by # what type of function is wrapped, or it can also be used as a context # manager, where the user needs to supply the correct synchronization # context. It is also possible to supply an object which appears to be a # synchronization primitive of some sort, by virtue of having release() # and acquire() methods. In that case that will be used directly as the # synchronization primitive without creating a separate lock against the # derived or supplied context. def synchronized(wrapped): # Determine if being passed an object which is a synchronization # primitive. We can't check by type for Lock, RLock, Semaphore etc, # as the means of creating them isn't the type. Therefore use the # existence of acquire() and release() methods. This is more # extensible anyway as it allows custom synchronization mechanisms. if hasattr(wrapped, 'acquire') and hasattr(wrapped, 'release'): # We remember what the original lock is and then return a new # decorator which acceses and locks it. When returning the new # decorator we wrap it with an object proxy so we can override # the context manager methods in case it is being used to wrap # synchronized statements with a 'with' statement. lock = wrapped @decorator def _synchronized(wrapped, instance, args, kwargs): # Execute the wrapped function while the original supplied # lock is held. with lock: return wrapped(*args, **kwargs) class _PartialDecorator(CallableObjectProxy): def __enter__(self): lock.acquire() return lock def __exit__(self, *args): lock.release() return _PartialDecorator(wrapped=_synchronized) # Following only apply when the lock is being created automatically # based on the context of what was supplied. In this case we supply # a final decorator, but need to use FunctionWrapper directly as we # want to derive from it to add context manager methods in in case it is # being used to wrap synchronized statements with a 'with' statement. def _synchronized_lock(context): # Attempt to retrieve the lock for the specific context. lock = vars(context).get('_synchronized_lock', None) if lock is None: # There is no existing lock defined for the context we # are dealing with so we need to create one. This needs # to be done in a way to guarantee there is only one # created, even if multiple threads try and create it at # the same time. We can't always use the setdefault() # method on the __dict__ for the context. This is the # case where the context is a class, as __dict__ is # actually a dictproxy. What we therefore do is use a # meta lock on this wrapper itself, to control the # creation and assignment of the lock attribute against # the context. meta_lock = vars(synchronized).setdefault( '_synchronized_meta_lock', Lock()) with meta_lock: # We need to check again for whether the lock we want # exists in case two threads were trying to create it # at the same time and were competing to create the # meta lock. lock = vars(context).get('_synchronized_lock', None) if lock is None: lock = RLock() setattr(context, '_synchronized_lock', lock) return lock def _synchronized_wrapper(wrapped, instance, args, kwargs): # Execute the wrapped function while the lock for the # desired context is held. If instance is None then the # wrapped function is used as the context. with _synchronized_lock(instance or wrapped): return wrapped(*args, **kwargs) class _FinalDecorator(FunctionWrapper): def __enter__(self): self._self_lock = _synchronized_lock(self.__wrapped__) self._self_lock.acquire() return self._self_lock def __exit__(self, *args): self._self_lock.release() return _FinalDecorator(wrapped=wrapped, wrapper=_synchronized_wrapper)
bsd-2-clause
[ 624, 2765, 859, 9031, 20419, 367, 18234, 1163, 20419, 199, 305, 5521, 465, 2005, 28829, 1202, 20419, 14, 199, 199, 624, 199, 199, 646, 984, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 4521, 19, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 692, 7843, 19, 26, 272, 1059, 63, 1313, 275, 620, 12, 339, 492, 12963, 272, 2146, 63, 275, 2519, 8, 10372, 12, 298, 1628, 531, 272, 2150, 12963, 199, 199, 2836, 26, 272, 1059, 63, 1313, 275, 7116, 12, 339, 347, 2146, 63, 1547, 600, 3131, 485, 15581, 10683, 403, 12, 485, 15781, 10683, 403, 304, 267, 408, 12049, 1233, 315, 282, 3231, 1041, 267, 340, 485, 15581, 63, 365, 488, 26, 288, 2787, 275, 984, 423, 20912, 8, 17, 9, 288, 485, 15581, 63, 275, 2787, 14, 70, 63, 8473, 288, 340, 485, 15781, 63, 365, 488, 26, 355, 485, 15781, 63, 275, 2787, 14, 70, 63, 9350, 288, 2150, 2787, 267, 916, 485, 15781, 63, 365, 488, 26, 288, 485, 15781, 63, 275, 485, 15581, 63, 267, 2146, 4852, 1628, 485, 600, 63, 315, 485, 15581, 3131, 485, 15781, 63, 6141, 199, 199, 504, 9143, 492, 7417, 199, 504, 6485, 492, 664, 15644, 12, 365, 765, 12, 365, 533, 12, 1475, 15644, 199, 504, 5055, 492, 12863, 199, 504, 5796, 492, 15536, 12, 820, 6432, 199, 199, 893, 26, 272, 687, 6485, 492, 4955, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 1275, 21148, 492, 334, 3481, 4590, 12, 21972, 3481, 4590, 12, 6935, 4936, 12, 272, 16975, 1692, 4936, 9, 199, 199, 3, 4431, 4185, 4975, 367, 314, 8072, 805, 1314, 911, 24393, 9842, 199, 3, 4382, 687, 314, 12146, 805, 14602, 314, 8072, 805, 880, 626, 199, 3, 3423, 4066, 465, 6485, 14, 29836, 1062, 6485, 14, 362, 2861, 15644, 1062, 199, 3, 6485, 14, 5233, 342, 436, 6485, 14, 362, 1365, 342, 372, 314, 3211, 2058, 199, 3, 1373, 3955, 4282, 14, 199, 199, 533, 485, 10200, 3481, 3034, 8, 16410, 1692, 4936, 304, 339, 347, 636, 826, 721, 277, 12, 8072, 63, 600, 12, 12146, 63, 600, 304, 267, 1613, 1547, 10200, 3481, 3034, 12, 291, 2843, 826, 721, 9130, 63, 600, 9, 267, 291, 423, 277, 63, 10394, 63, 600, 275, 12146, 63, 600, 339, 768, 1829, 272, 347, 512, 63, 30513, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 30513, 339, 768, 1829, 272, 347, 512, 63, 600, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 600, 339, 768, 1829, 272, 347, 512, 63, 2469, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 2469, 339, 768, 1829, 272, 347, 512, 63, 829, 2118, 30513, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 829, 2118, 30513, 339, 768, 1829, 272, 347, 512, 63, 1391, 1247, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 1391, 1247, 199, 199, 533, 485, 10200, 3481, 11762, 13095, 8, 16410, 1692, 4936, 304, 339, 347, 636, 826, 721, 277, 12, 8072, 12, 12146, 304, 267, 1613, 1547, 10200, 3481, 11762, 13095, 12, 291, 2843, 826, 721, 9130, 9, 267, 291, 423, 277, 63, 10394, 275, 12146, 339, 768, 1829, 272, 347, 636, 600, 721, 277, 304, 267, 372, 485, 10200, 3481, 3034, 8, 277, 855, 9130, 4914, 600, 3108, 355, 291, 423, 277, 63, 10394, 855, 600, 3368, 339, 768, 1829, 272, 347, 636, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 855, 4322, 363, 339, 768, 1829, 272, 347, 636, 829, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 855, 829, 4322, 363, 339, 768, 1829, 272, 347, 636, 5233, 721, 277, 304, 267, 340, 283, 5233, 7, 440, 315, 7992, 837, 288, 372, 291, 423, 277, 63, 10394, 855, 5233, 363, 267, 587, 26, 288, 327, 6855, 1133, 2040, 642, 370, 2449, 641, 2018, 650, 587, 652, 26945, 288, 327, 4012, 370, 1808, 636, 9130, 3108, 1325, 626, 911, 506, 314, 288, 327, 6835, 805, 781, 2934, 370, 23519, 314, 4955, 288, 327, 687, 14, 20227, 3550, 314, 4955, 26495, 14, 953, 372, 4955, 8, 277, 423, 277, 63, 10394, 9, 339, 340, 7843, 18, 26, 267, 2562, 63, 600, 275, 636, 600, 363, 267, 2562, 63, 4322, 275, 636, 4322, 363, 199, 199, 533, 485, 8934, 10200, 4590, 8, 8934, 3481, 4590, 304, 339, 768, 1829, 272, 347, 636, 1532, 721, 277, 304, 267, 372, 485, 10200, 3481, 11762, 13095, 8, 277, 855, 9130, 4914, 1532, 3108, 355, 291, 423, 277, 63, 1708, 423, 277, 63, 10394, 9, 339, 340, 7843, 18, 26, 267, 3416, 63, 1532, 275, 636, 1532, 363, 199, 199, 533, 4431, 4185, 4590, 8, 3481, 4590, 304, 339, 636, 3556, 63, 1593, 63, 5029, 363, 275, 485, 8934, 10200, 4590, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 12146, 275, 2074, 14, 1935, 360, 10394, 358, 267, 1613, 8, 10200, 4590, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 423, 277, 63, 16380, 275, 485, 10200, 3481, 11762, 13095, 8, 355, 291, 855, 9130, 3108, 12146, 9, 267, 291, 423, 277, 63, 10394, 275, 12146, 339, 768, 1829, 272, 347, 636, 600, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 600, 363, 339, 768, 1829, 272, 347, 636, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 4322, 363, 339, 768, 1829, 272, 347, 636, 829, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 829, 4322, 363, 339, 340, 7843, 18, 26, 267, 2562, 63, 600, 275, 636, 600, 363, 267, 2562, 63, 4322, 275, 636, 4322, 363, 339, 768, 1829, 272, 347, 636, 5233, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 5233, 363, 199, 199, 533, 4431, 4185, 2927, 8, 785, 304, 272, 347, 636, 1250, 721, 277, 12, 8072, 304, 267, 746, 4279, 342, 199, 199, 533, 1487, 4170, 972, 10200 ]
[ 2765, 859, 9031, 20419, 367, 18234, 1163, 20419, 199, 305, 5521, 465, 2005, 28829, 1202, 20419, 14, 199, 199, 624, 199, 199, 646, 984, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 4521, 19, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 692, 7843, 19, 26, 272, 1059, 63, 1313, 275, 620, 12, 339, 492, 12963, 272, 2146, 63, 275, 2519, 8, 10372, 12, 298, 1628, 531, 272, 2150, 12963, 199, 199, 2836, 26, 272, 1059, 63, 1313, 275, 7116, 12, 339, 347, 2146, 63, 1547, 600, 3131, 485, 15581, 10683, 403, 12, 485, 15781, 10683, 403, 304, 267, 408, 12049, 1233, 315, 282, 3231, 1041, 267, 340, 485, 15581, 63, 365, 488, 26, 288, 2787, 275, 984, 423, 20912, 8, 17, 9, 288, 485, 15581, 63, 275, 2787, 14, 70, 63, 8473, 288, 340, 485, 15781, 63, 365, 488, 26, 355, 485, 15781, 63, 275, 2787, 14, 70, 63, 9350, 288, 2150, 2787, 267, 916, 485, 15781, 63, 365, 488, 26, 288, 485, 15781, 63, 275, 485, 15581, 63, 267, 2146, 4852, 1628, 485, 600, 63, 315, 485, 15581, 3131, 485, 15781, 63, 6141, 199, 199, 504, 9143, 492, 7417, 199, 504, 6485, 492, 664, 15644, 12, 365, 765, 12, 365, 533, 12, 1475, 15644, 199, 504, 5055, 492, 12863, 199, 504, 5796, 492, 15536, 12, 820, 6432, 199, 199, 893, 26, 272, 687, 6485, 492, 4955, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 1275, 21148, 492, 334, 3481, 4590, 12, 21972, 3481, 4590, 12, 6935, 4936, 12, 272, 16975, 1692, 4936, 9, 199, 199, 3, 4431, 4185, 4975, 367, 314, 8072, 805, 1314, 911, 24393, 9842, 199, 3, 4382, 687, 314, 12146, 805, 14602, 314, 8072, 805, 880, 626, 199, 3, 3423, 4066, 465, 6485, 14, 29836, 1062, 6485, 14, 362, 2861, 15644, 1062, 199, 3, 6485, 14, 5233, 342, 436, 6485, 14, 362, 1365, 342, 372, 314, 3211, 2058, 199, 3, 1373, 3955, 4282, 14, 199, 199, 533, 485, 10200, 3481, 3034, 8, 16410, 1692, 4936, 304, 339, 347, 636, 826, 721, 277, 12, 8072, 63, 600, 12, 12146, 63, 600, 304, 267, 1613, 1547, 10200, 3481, 3034, 12, 291, 2843, 826, 721, 9130, 63, 600, 9, 267, 291, 423, 277, 63, 10394, 63, 600, 275, 12146, 63, 600, 339, 768, 1829, 272, 347, 512, 63, 30513, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 30513, 339, 768, 1829, 272, 347, 512, 63, 600, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 600, 339, 768, 1829, 272, 347, 512, 63, 2469, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 2469, 339, 768, 1829, 272, 347, 512, 63, 829, 2118, 30513, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 829, 2118, 30513, 339, 768, 1829, 272, 347, 512, 63, 1391, 1247, 8, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 63, 600, 14, 331, 63, 1391, 1247, 199, 199, 533, 485, 10200, 3481, 11762, 13095, 8, 16410, 1692, 4936, 304, 339, 347, 636, 826, 721, 277, 12, 8072, 12, 12146, 304, 267, 1613, 1547, 10200, 3481, 11762, 13095, 12, 291, 2843, 826, 721, 9130, 9, 267, 291, 423, 277, 63, 10394, 275, 12146, 339, 768, 1829, 272, 347, 636, 600, 721, 277, 304, 267, 372, 485, 10200, 3481, 3034, 8, 277, 855, 9130, 4914, 600, 3108, 355, 291, 423, 277, 63, 10394, 855, 600, 3368, 339, 768, 1829, 272, 347, 636, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 855, 4322, 363, 339, 768, 1829, 272, 347, 636, 829, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 10394, 855, 829, 4322, 363, 339, 768, 1829, 272, 347, 636, 5233, 721, 277, 304, 267, 340, 283, 5233, 7, 440, 315, 7992, 837, 288, 372, 291, 423, 277, 63, 10394, 855, 5233, 363, 267, 587, 26, 288, 327, 6855, 1133, 2040, 642, 370, 2449, 641, 2018, 650, 587, 652, 26945, 288, 327, 4012, 370, 1808, 636, 9130, 3108, 1325, 626, 911, 506, 314, 288, 327, 6835, 805, 781, 2934, 370, 23519, 314, 4955, 288, 327, 687, 14, 20227, 3550, 314, 4955, 26495, 14, 953, 372, 4955, 8, 277, 423, 277, 63, 10394, 9, 339, 340, 7843, 18, 26, 267, 2562, 63, 600, 275, 636, 600, 363, 267, 2562, 63, 4322, 275, 636, 4322, 363, 199, 199, 533, 485, 8934, 10200, 4590, 8, 8934, 3481, 4590, 304, 339, 768, 1829, 272, 347, 636, 1532, 721, 277, 304, 267, 372, 485, 10200, 3481, 11762, 13095, 8, 277, 855, 9130, 4914, 1532, 3108, 355, 291, 423, 277, 63, 1708, 423, 277, 63, 10394, 9, 339, 340, 7843, 18, 26, 267, 3416, 63, 1532, 275, 636, 1532, 363, 199, 199, 533, 4431, 4185, 4590, 8, 3481, 4590, 304, 339, 636, 3556, 63, 1593, 63, 5029, 363, 275, 485, 8934, 10200, 4590, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 12146, 275, 2074, 14, 1935, 360, 10394, 358, 267, 1613, 8, 10200, 4590, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 423, 277, 63, 16380, 275, 485, 10200, 3481, 11762, 13095, 8, 355, 291, 855, 9130, 3108, 12146, 9, 267, 291, 423, 277, 63, 10394, 275, 12146, 339, 768, 1829, 272, 347, 636, 600, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 600, 363, 339, 768, 1829, 272, 347, 636, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 4322, 363, 339, 768, 1829, 272, 347, 636, 829, 4322, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 829, 4322, 363, 339, 340, 7843, 18, 26, 267, 2562, 63, 600, 275, 636, 600, 363, 267, 2562, 63, 4322, 275, 636, 4322, 363, 339, 768, 1829, 272, 347, 636, 5233, 721, 277, 304, 267, 372, 291, 423, 277, 63, 16380, 855, 5233, 363, 199, 199, 533, 4431, 4185, 2927, 8, 785, 304, 272, 347, 636, 1250, 721, 277, 12, 8072, 304, 267, 746, 4279, 342, 199, 199, 533, 1487, 4170, 972, 10200, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
iglpdc/nipype
nipype/interfaces/mrtrix3/tests/test_auto_Tractography.py
10
3260
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT from ....testing import assert_equal from ..tracking import Tractography def test_Tractography_inputs(): input_map = dict(act_file=dict(argstr='-act %s', ), algorithm=dict(argstr='-algorithm %s', usedefault=True, ), angle=dict(argstr='-angle %f', ), args=dict(argstr='%s', ), backtrack=dict(argstr='-backtrack', ), bval_scale=dict(argstr='-bvalue_scaling %s', ), crop_at_gmwmi=dict(argstr='-crop_at_gmwmi', ), cutoff=dict(argstr='-cutoff %f', ), cutoff_init=dict(argstr='-initcutoff %f', ), downsample=dict(argstr='-downsample %f', ), environ=dict(nohash=True, usedefault=True, ), grad_file=dict(argstr='-grad %s', ), grad_fsl=dict(argstr='-fslgrad %s %s', ), ignore_exception=dict(nohash=True, usedefault=True, ), in_bval=dict(), in_bvec=dict(argstr='-fslgrad %s %s', ), in_file=dict(argstr='%s', mandatory=True, position=-2, ), init_dir=dict(argstr='-initdirection %f,%f,%f', ), max_length=dict(argstr='-maxlength %f', ), max_seed_attempts=dict(argstr='-max_seed_attempts %d', ), max_tracks=dict(argstr='-maxnum %d', ), min_length=dict(argstr='-minlength %f', ), n_samples=dict(argstr='-samples %d', ), n_tracks=dict(argstr='-number %d', ), n_trials=dict(argstr='-trials %d', ), noprecompt=dict(argstr='-noprecomputed', ), nthreads=dict(argstr='-nthreads %d', nohash=True, ), out_file=dict(argstr='%s', mandatory=True, position=-1, usedefault=True, ), out_seeds=dict(argstr='-output_seeds %s', ), power=dict(argstr='-power %d', ), roi_excl=dict(argstr='-exclude %s', ), roi_incl=dict(argstr='-include %s', ), roi_mask=dict(argstr='-mask %s', ), seed_dynamic=dict(argstr='-seed_dynamic %s', ), seed_gmwmi=dict(argstr='-seed_gmwmi %s', requires=['act_file'], ), seed_grid_voxel=dict(argstr='-seed_grid_per_voxel %s %d', xor=['seed_image', 'seed_rnd_voxel'], ), seed_image=dict(argstr='-seed_image %s', ), seed_rejection=dict(argstr='-seed_rejection %s', ), seed_rnd_voxel=dict(argstr='-seed_random_per_voxel %s %d', xor=['seed_image', 'seed_grid_voxel'], ), seed_sphere=dict(argstr='-seed_sphere %f,%f,%f,%f', ), sph_trait=dict(argstr='%f,%f,%f,%f', ), step_size=dict(argstr='-step %f', ), stop=dict(argstr='-stop', ), terminal_output=dict(nohash=True, ), unidirectional=dict(argstr='-unidirectional', ), use_rk4=dict(argstr='-rk4', ), ) inputs = Tractography.input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): yield assert_equal, getattr(inputs.traits()[key], metakey), value def test_Tractography_outputs(): output_map = dict(out_file=dict(), out_seeds=dict(), ) outputs = Tractography.output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): yield assert_equal, getattr(outputs.traits()[key], metakey), value
bsd-3-clause
[ 3, 25420, 13, 12795, 6989, 701, 7249, 15, 1074, 7273, 14, 647, 446, 3506, 2845, 24981, 199, 504, 29222, 4776, 492, 702, 63, 1452, 199, 504, 2508, 14428, 492, 377, 1957, 32157, 421, 199, 318, 511, 63, 52, 1957, 32157, 63, 3711, 837, 272, 1324, 63, 1130, 275, 1211, 8, 2442, 63, 493, 29, 807, 8, 21371, 18274, 2442, 450, 83, 297, 272, 2318, 272, 5563, 29, 807, 8, 21371, 18274, 8833, 450, 83, 297, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 9324, 29, 807, 8, 21371, 18274, 4593, 450, 70, 297, 272, 2318, 272, 1249, 29, 807, 8, 21371, 9569, 83, 297, 272, 2318, 272, 1771, 3885, 29, 807, 8, 21371, 18274, 894, 3885, 297, 272, 2318, 272, 330, 637, 63, 3467, 29, 807, 8, 21371, 18274, 66, 585, 63, 12153, 450, 83, 297, 272, 2318, 272, 18366, 63, 292, 63, 13844, 87, 2664, 29, 807, 8, 21371, 18274, 15816, 63, 292, 63, 13844, 87, 2664, 297, 272, 2318, 272, 17875, 29, 807, 8, 21371, 18274, 17708, 450, 70, 297, 272, 2318, 272, 17875, 63, 826, 29, 807, 8, 21371, 18274, 826, 17708, 450, 70, 297, 272, 2318, 272, 366, 23311, 865, 29, 807, 8, 21371, 18274, 68, 23311, 865, 450, 70, 297, 272, 2318, 272, 6160, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 7659, 63, 493, 29, 807, 8, 21371, 18274, 6017, 450, 83, 297, 272, 2318, 272, 7659, 63, 2319, 76, 29, 807, 8, 21371, 18274, 2319, 76, 6017, 450, 83, 450, 83, 297, 272, 2318, 272, 3686, 63, 1971, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 315, 63, 66, 637, 29, 807, 1062, 272, 315, 63, 66, 6046, 29, 807, 8, 21371, 18274, 2319, 76, 6017, 450, 83, 450, 83, 297, 272, 2318, 272, 315, 63, 493, 29, 807, 8, 21371, 9569, 83, 297, 272, 15230, 29, 549, 12, 272, 3421, 4022, 18, 12, 272, 2318, 272, 4205, 63, 694, 29, 807, 8, 21371, 18274, 826, 6874, 450, 70, 8719, 70, 8719, 70, 297, 272, 2318, 272, 1390, 63, 1267, 29, 807, 8, 21371, 18274, 988, 1267, 450, 70, 297, 272, 2318, 272, 1390, 63, 5176, 63, 13143, 29, 807, 8, 21371, 18274, 988, 63, 5176, 63, 13143, 450, 68, 297, 272, 2318, 272, 1390, 63, 16274, 29, 807, 8, 21371, 18274, 988, 1507, 450, 68, 297, 272, 2318, 272, 1748, 63, 1267, 29, 807, 8, 21371, 18274, 827, 1267, 450, 70, 297, 272, 2318, 272, 302, 63, 3356, 29, 807, 8, 21371, 18274, 3356, 450, 68, 297, 272, 2318, 272, 302, 63, 16274, 29, 807, 8, 21371, 18274, 1955, 450, 68, 297, 272, 2318, 272, 302, 63, 24684, 29, 807, 8, 21371, 18274, 24684, 450, 68, 297, 272, 2318, 272, 302, 411, 264, 863, 84, 29, 807, 8, 21371, 18274, 20443, 264, 14378, 297, 272, 2318, 272, 302, 6962, 29, 807, 8, 21371, 18274, 78, 6962, 450, 68, 297, 272, 949, 2227, 29, 549, 12, 272, 2318, 272, 734, 63, 493, 29, 807, 8, 21371, 9569, 83, 297, 272, 15230, 29, 549, 12, 272, 3421, 4022, 17, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 734, 63, 5176, 83, 29, 807, 8, 21371, 18274, 1199, 63, 5176, 83, 450, 83, 297, 272, 2318, 272, 7074, 29, 807, 8, 21371, 18274, 5652, 450, 68, 297, 272, 2318, 272, 30240, 63, 476, 429, 29, 807, 8, 21371, 18274, 5473, 450, 83, 297, 272, 2318, 272, 30240, 63, 31941, 29, 807, 8, 21371, 18274, 2613, 450, 83, 297, 272, 2318, 272, 30240, 63, 2629, 29, 807, 8, 21371, 18274, 2629, 450, 83, 297, 272, 2318, 272, 6347, 63, 7764, 29, 807, 8, 21371, 18274, 5176, 63, 7764, 450, 83, 297, 272, 2318, 272, 6347, 63, 13844, 87, 2664, 29, 807, 8, 21371, 18274, 5176, 63, 13844, 87, 2664, 450, 83, 297, 272, 5074, 2968, 2442, 63, 493, 995, 272, 2318, 272, 6347, 63, 3825, 63, 2392, 31418, 29, 807, 8, 21371, 18274, 5176, 63, 3825, 63, 529, 63, 2392, 31418, 450, 83, 450, 68, 297, 272, 31770, 2968, 5176, 63, 1569, 297, 283, 5176, 63, 30006, 63, 2392, 31418, 995, 272, 2318, 272, 6347, 63, 1569, 29, 807, 8, 21371, 18274, 5176, 63, 1569, 450, 83, 297, 272, 2318, 272, 6347, 63, 264, 8923, 29, 807, 8, 21371, 18274, 5176, 63, 264, 8923, 450, 83, 297, 272, 2318, 272, 6347, 63, 30006, 63, 2392, 31418, 29, 807, 8, 21371, 18274, 5176, 63, 2355, 63, 529, 63, 2392, 31418, 450, 83, 450, 68, 297, 272, 31770, 2968, 5176, 63, 1569, 297, 283, 5176, 63, 3825, 63, 2392, 31418, 995, 272, 2318, 272, 6347, 63, 14980, 29, 807, 8, 21371, 18274, 5176, 63, 14980, 450, 70, 8719, 70, 8719, 70, 8719, 70, 297, 272, 2318, 272, 308, 838, 63, 22687, 29, 807, 8, 21371, 9569, 70, 8719, 70, 8719, 70, 8719, 70, 297, 272, 2318, 272, 3650, 63, 890, 29, 807, 8, 21371, 18274, 2926, 450, 70, 297, 272, 2318, 272, 3631, 29, 807, 8, 21371, 18274, 2379, 297, 272, 2318, 272, 11167, 63, 1199, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 2318, 272, 15439, 21360, 29, 807, 8, 21371, 18274, 5411, 21360, 297, 272, 2318, 272, 675, 63, 23992, 20, 29, 807, 8, 21371, 18274, 23992, 20, 297, 272, 2318, 272, 776, 272, 4153, 275, 377, 1957, 32157, 14, 1210, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1210, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 8, 3711, 14, 17668, 3430, 498, 467, 3404, 498, 395, 574, 421, 199, 318, 511, 63, 52, 1957, 32157, 63, 4467, 837, 272, 1072, 63, 1130, 275, 1211, 8, 548, 63, 493, 29, 807, 1062, 272, 734, 63, 5176, 83, 29, 807, 1062, 272, 776, 272, 4704, 275, 377, 1957, 32157, 14, 1199, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1199, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519 ]
[ 25420, 13, 12795, 6989, 701, 7249, 15, 1074, 7273, 14, 647, 446, 3506, 2845, 24981, 199, 504, 29222, 4776, 492, 702, 63, 1452, 199, 504, 2508, 14428, 492, 377, 1957, 32157, 421, 199, 318, 511, 63, 52, 1957, 32157, 63, 3711, 837, 272, 1324, 63, 1130, 275, 1211, 8, 2442, 63, 493, 29, 807, 8, 21371, 18274, 2442, 450, 83, 297, 272, 2318, 272, 5563, 29, 807, 8, 21371, 18274, 8833, 450, 83, 297, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 9324, 29, 807, 8, 21371, 18274, 4593, 450, 70, 297, 272, 2318, 272, 1249, 29, 807, 8, 21371, 9569, 83, 297, 272, 2318, 272, 1771, 3885, 29, 807, 8, 21371, 18274, 894, 3885, 297, 272, 2318, 272, 330, 637, 63, 3467, 29, 807, 8, 21371, 18274, 66, 585, 63, 12153, 450, 83, 297, 272, 2318, 272, 18366, 63, 292, 63, 13844, 87, 2664, 29, 807, 8, 21371, 18274, 15816, 63, 292, 63, 13844, 87, 2664, 297, 272, 2318, 272, 17875, 29, 807, 8, 21371, 18274, 17708, 450, 70, 297, 272, 2318, 272, 17875, 63, 826, 29, 807, 8, 21371, 18274, 826, 17708, 450, 70, 297, 272, 2318, 272, 366, 23311, 865, 29, 807, 8, 21371, 18274, 68, 23311, 865, 450, 70, 297, 272, 2318, 272, 6160, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 7659, 63, 493, 29, 807, 8, 21371, 18274, 6017, 450, 83, 297, 272, 2318, 272, 7659, 63, 2319, 76, 29, 807, 8, 21371, 18274, 2319, 76, 6017, 450, 83, 450, 83, 297, 272, 2318, 272, 3686, 63, 1971, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 315, 63, 66, 637, 29, 807, 1062, 272, 315, 63, 66, 6046, 29, 807, 8, 21371, 18274, 2319, 76, 6017, 450, 83, 450, 83, 297, 272, 2318, 272, 315, 63, 493, 29, 807, 8, 21371, 9569, 83, 297, 272, 15230, 29, 549, 12, 272, 3421, 4022, 18, 12, 272, 2318, 272, 4205, 63, 694, 29, 807, 8, 21371, 18274, 826, 6874, 450, 70, 8719, 70, 8719, 70, 297, 272, 2318, 272, 1390, 63, 1267, 29, 807, 8, 21371, 18274, 988, 1267, 450, 70, 297, 272, 2318, 272, 1390, 63, 5176, 63, 13143, 29, 807, 8, 21371, 18274, 988, 63, 5176, 63, 13143, 450, 68, 297, 272, 2318, 272, 1390, 63, 16274, 29, 807, 8, 21371, 18274, 988, 1507, 450, 68, 297, 272, 2318, 272, 1748, 63, 1267, 29, 807, 8, 21371, 18274, 827, 1267, 450, 70, 297, 272, 2318, 272, 302, 63, 3356, 29, 807, 8, 21371, 18274, 3356, 450, 68, 297, 272, 2318, 272, 302, 63, 16274, 29, 807, 8, 21371, 18274, 1955, 450, 68, 297, 272, 2318, 272, 302, 63, 24684, 29, 807, 8, 21371, 18274, 24684, 450, 68, 297, 272, 2318, 272, 302, 411, 264, 863, 84, 29, 807, 8, 21371, 18274, 20443, 264, 14378, 297, 272, 2318, 272, 302, 6962, 29, 807, 8, 21371, 18274, 78, 6962, 450, 68, 297, 272, 949, 2227, 29, 549, 12, 272, 2318, 272, 734, 63, 493, 29, 807, 8, 21371, 9569, 83, 297, 272, 15230, 29, 549, 12, 272, 3421, 4022, 17, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 734, 63, 5176, 83, 29, 807, 8, 21371, 18274, 1199, 63, 5176, 83, 450, 83, 297, 272, 2318, 272, 7074, 29, 807, 8, 21371, 18274, 5652, 450, 68, 297, 272, 2318, 272, 30240, 63, 476, 429, 29, 807, 8, 21371, 18274, 5473, 450, 83, 297, 272, 2318, 272, 30240, 63, 31941, 29, 807, 8, 21371, 18274, 2613, 450, 83, 297, 272, 2318, 272, 30240, 63, 2629, 29, 807, 8, 21371, 18274, 2629, 450, 83, 297, 272, 2318, 272, 6347, 63, 7764, 29, 807, 8, 21371, 18274, 5176, 63, 7764, 450, 83, 297, 272, 2318, 272, 6347, 63, 13844, 87, 2664, 29, 807, 8, 21371, 18274, 5176, 63, 13844, 87, 2664, 450, 83, 297, 272, 5074, 2968, 2442, 63, 493, 995, 272, 2318, 272, 6347, 63, 3825, 63, 2392, 31418, 29, 807, 8, 21371, 18274, 5176, 63, 3825, 63, 529, 63, 2392, 31418, 450, 83, 450, 68, 297, 272, 31770, 2968, 5176, 63, 1569, 297, 283, 5176, 63, 30006, 63, 2392, 31418, 995, 272, 2318, 272, 6347, 63, 1569, 29, 807, 8, 21371, 18274, 5176, 63, 1569, 450, 83, 297, 272, 2318, 272, 6347, 63, 264, 8923, 29, 807, 8, 21371, 18274, 5176, 63, 264, 8923, 450, 83, 297, 272, 2318, 272, 6347, 63, 30006, 63, 2392, 31418, 29, 807, 8, 21371, 18274, 5176, 63, 2355, 63, 529, 63, 2392, 31418, 450, 83, 450, 68, 297, 272, 31770, 2968, 5176, 63, 1569, 297, 283, 5176, 63, 3825, 63, 2392, 31418, 995, 272, 2318, 272, 6347, 63, 14980, 29, 807, 8, 21371, 18274, 5176, 63, 14980, 450, 70, 8719, 70, 8719, 70, 8719, 70, 297, 272, 2318, 272, 308, 838, 63, 22687, 29, 807, 8, 21371, 9569, 70, 8719, 70, 8719, 70, 8719, 70, 297, 272, 2318, 272, 3650, 63, 890, 29, 807, 8, 21371, 18274, 2926, 450, 70, 297, 272, 2318, 272, 3631, 29, 807, 8, 21371, 18274, 2379, 297, 272, 2318, 272, 11167, 63, 1199, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 2318, 272, 15439, 21360, 29, 807, 8, 21371, 18274, 5411, 21360, 297, 272, 2318, 272, 675, 63, 23992, 20, 29, 807, 8, 21371, 18274, 23992, 20, 297, 272, 2318, 272, 776, 272, 4153, 275, 377, 1957, 32157, 14, 1210, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1210, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 8, 3711, 14, 17668, 3430, 498, 467, 3404, 498, 395, 574, 421, 199, 318, 511, 63, 52, 1957, 32157, 63, 4467, 837, 272, 1072, 63, 1130, 275, 1211, 8, 548, 63, 493, 29, 807, 1062, 272, 734, 63, 5176, 83, 29, 807, 1062, 272, 776, 272, 4704, 275, 377, 1957, 32157, 14, 1199, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1199, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
GitAngel/django
tests/template_tests/test_library.py
413
3753
from django.template import Library from django.template.base import Node from django.test import TestCase class FilterRegistrationTests(TestCase): def setUp(self): self.library = Library() def test_filter(self): @self.library.filter def func(): return '' self.assertEqual(self.library.filters['func'], func) def test_filter_parens(self): @self.library.filter() def func(): return '' self.assertEqual(self.library.filters['func'], func) def test_filter_name_arg(self): @self.library.filter('name') def func(): return '' self.assertEqual(self.library.filters['name'], func) def test_filter_name_kwarg(self): @self.library.filter(name='name') def func(): return '' self.assertEqual(self.library.filters['name'], func) def test_filter_call(self): def func(): return '' self.library.filter('name', func) self.assertEqual(self.library.filters['name'], func) def test_filter_invalid(self): msg = "Unsupported arguments to Library.filter: (None, '')" with self.assertRaisesMessage(ValueError, msg): self.library.filter(None, '') class InclusionTagRegistrationTests(TestCase): def setUp(self): self.library = Library() def test_inclusion_tag(self): @self.library.inclusion_tag('template.html') def func(): return '' self.assertIn('func', self.library.tags) def test_inclusion_tag_name(self): @self.library.inclusion_tag('template.html', name='name') def func(): return '' self.assertIn('name', self.library.tags) class SimpleTagRegistrationTests(TestCase): def setUp(self): self.library = Library() def test_simple_tag(self): @self.library.simple_tag def func(): return '' self.assertIn('func', self.library.tags) def test_simple_tag_parens(self): @self.library.simple_tag() def func(): return '' self.assertIn('func', self.library.tags) def test_simple_tag_name_kwarg(self): @self.library.simple_tag(name='name') def func(): return '' self.assertIn('name', self.library.tags) def test_simple_tag_invalid(self): msg = "Invalid arguments provided to simple_tag" with self.assertRaisesMessage(ValueError, msg): self.library.simple_tag('invalid') class TagRegistrationTests(TestCase): def setUp(self): self.library = Library() def test_tag(self): @self.library.tag def func(parser, token): return Node() self.assertEqual(self.library.tags['func'], func) def test_tag_parens(self): @self.library.tag() def func(parser, token): return Node() self.assertEqual(self.library.tags['func'], func) def test_tag_name_arg(self): @self.library.tag('name') def func(parser, token): return Node() self.assertEqual(self.library.tags['name'], func) def test_tag_name_kwarg(self): @self.library.tag(name='name') def func(parser, token): return Node() self.assertEqual(self.library.tags['name'], func) def test_tag_call(self): def func(parser, token): return Node() self.library.tag('name', func) self.assertEqual(self.library.tags['name'], func) def test_tag_invalid(self): msg = "Unsupported arguments to Library.tag: (None, '')" with self.assertRaisesMessage(ValueError, msg): self.library.tag(None, '')
bsd-3-clause
[ 504, 1639, 14, 1160, 492, 11243, 199, 504, 1639, 14, 1160, 14, 1095, 492, 5013, 199, 504, 1639, 14, 396, 492, 7640, 421, 199, 533, 9388, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 1541, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 31910, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 342, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 354, 63, 1273, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 360, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 354, 63, 12745, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 8, 354, 534, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 1250, 8, 277, 304, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4342, 14, 1541, 360, 354, 297, 2562, 9, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 3197, 8, 277, 304, 267, 1499, 275, 298, 12647, 2368, 370, 11243, 14, 1541, 26, 334, 403, 12, 4074, 2, 267, 543, 291, 14, 14638, 8, 3393, 12, 1499, 304, 288, 291, 14, 4342, 14, 1541, 8, 403, 12, 4074, 421, 199, 533, 1010, 10248, 1931, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 24265, 63, 1450, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 24265, 63, 1450, 360, 1160, 14, 1360, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 1532, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 24265, 63, 1450, 63, 354, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 24265, 63, 1450, 360, 1160, 14, 1360, 297, 536, 534, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 354, 297, 291, 14, 4342, 14, 2969, 9, 421, 199, 533, 5870, 1931, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 4129, 63, 1450, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 4129, 63, 1450, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 1532, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 4129, 63, 1450, 63, 31910, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 4129, 63, 1450, 342, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 1532, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 4129, 63, 1450, 63, 354, 63, 12745, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 4129, 63, 1450, 8, 354, 534, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 354, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 4129, 63, 1450, 63, 3197, 8, 277, 304, 267, 1499, 275, 298, 3364, 2368, 2741, 370, 3486, 63, 1450, 2, 267, 543, 291, 14, 14638, 8, 3393, 12, 1499, 304, 288, 291, 14, 4342, 14, 4129, 63, 1450, 360, 3197, 358, 421, 199, 533, 8053, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 1450, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 31910, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 342, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 354, 63, 1273, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 360, 354, 358, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 354, 63, 12745, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 8, 354, 534, 354, 358, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 1250, 8, 277, 304, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 4342, 14, 1450, 360, 354, 297, 2562, 9, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 3197, 8, 277, 304, 267, 1499, 275, 298, 12647, 2368, 370, 11243, 14, 1450, 26, 334, 403, 12, 4074, 2, 267, 543, 291, 14, 14638, 8, 3393, 12, 1499, 304, 288, 291, 14, 4342, 14, 1450, 8, 403, 12, 4074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 1160, 492, 11243, 199, 504, 1639, 14, 1160, 14, 1095, 492, 5013, 199, 504, 1639, 14, 396, 492, 7640, 421, 199, 533, 9388, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 1541, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 31910, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 342, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 354, 63, 1273, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 360, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 354, 63, 12745, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1541, 8, 354, 534, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 1250, 8, 277, 304, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4342, 14, 1541, 360, 354, 297, 2562, 9, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 4273, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1541, 63, 3197, 8, 277, 304, 267, 1499, 275, 298, 12647, 2368, 370, 11243, 14, 1541, 26, 334, 403, 12, 4074, 2, 267, 543, 291, 14, 14638, 8, 3393, 12, 1499, 304, 288, 291, 14, 4342, 14, 1541, 8, 403, 12, 4074, 421, 199, 533, 1010, 10248, 1931, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 24265, 63, 1450, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 24265, 63, 1450, 360, 1160, 14, 1360, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 1532, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 24265, 63, 1450, 63, 354, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 24265, 63, 1450, 360, 1160, 14, 1360, 297, 536, 534, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 354, 297, 291, 14, 4342, 14, 2969, 9, 421, 199, 533, 5870, 1931, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 4129, 63, 1450, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 4129, 63, 1450, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 1532, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 4129, 63, 1450, 63, 31910, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 4129, 63, 1450, 342, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 1532, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 4129, 63, 1450, 63, 354, 63, 12745, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 4129, 63, 1450, 8, 354, 534, 354, 358, 267, 347, 2562, 837, 288, 372, 2125, 267, 291, 14, 4080, 360, 354, 297, 291, 14, 4342, 14, 2969, 9, 339, 347, 511, 63, 4129, 63, 1450, 63, 3197, 8, 277, 304, 267, 1499, 275, 298, 3364, 2368, 2741, 370, 3486, 63, 1450, 2, 267, 543, 291, 14, 14638, 8, 3393, 12, 1499, 304, 288, 291, 14, 4342, 14, 4129, 63, 1450, 360, 3197, 358, 421, 199, 533, 8053, 11757, 2925, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4342, 275, 11243, 342, 339, 347, 511, 63, 1450, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 31910, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 342, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 1532, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 354, 63, 1273, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 360, 354, 358, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 354, 63, 12745, 8, 277, 304, 267, 768, 277, 14, 4342, 14, 1450, 8, 354, 534, 354, 358, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 1250, 8, 277, 304, 267, 347, 2562, 8, 2087, 12, 1526, 304, 288, 372, 5013, 342, 267, 291, 14, 4342, 14, 1450, 360, 354, 297, 2562, 9, 267, 291, 14, 629, 8, 277, 14, 4342, 14, 2969, 459, 354, 995, 2562, 9, 339, 347, 511, 63, 1450, 63, 3197, 8, 277, 304, 267, 1499, 275, 298, 12647, 2368, 370, 11243, 14, 1450, 26, 334, 403, 12, 4074, 2, 267, 543, 291, 14, 14638, 8, 3393, 12, 1499, 304, 288, 291, 14, 4342, 14, 1450, 8, 403, 12, 4074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
richardcs/ansible
lib/ansible/modules/net_tools/nios/nios_network.py
14
7756
#!/usr/bin/python # Copyright (c) 2018 Red Hat, Inc. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'certified'} DOCUMENTATION = ''' --- module: nios_network version_added: "2.5" author: "Peter Sprygada (@privateip)" short_description: Configure Infoblox NIOS network object description: - Adds and/or removes instances of network objects from Infoblox NIOS servers. This module manages NIOS C(network) objects using the Infoblox WAPI interface over REST. - Supports both IPV4 and IPV6 internet protocols requirements: - infoblox-client extends_documentation_fragment: nios options: network: description: - Specifies the network to add or remove from the system. The value should use CIDR notation. required: true aliases: - name - cidr network_view: description: - Configures the name of the network view to associate with this configured instance. required: true default: default options: description: - Configures the set of DHCP options to be included as part of the configured network instance. This argument accepts a list of values (see suboptions). When configuring suboptions at least one of C(name) or C(num) must be specified. suboptions: name: description: - The name of the DHCP option to configure num: description: - The number of the DHCP option to configure value: description: - The value of the DHCP option specified by C(name) required: true use_option: description: - Only applies to a subset of options (see NIOS API documentation) type: bool default: 'yes' vendor_class: description: - The name of the space this DHCP option is associated to default: DHCP extattrs: description: - Allows for the configuration of Extensible Attributes on the instance of the object. This argument accepts a set of key / value pairs for configuration. comment: description: - Configures a text string comment to be associated with the instance of this object. The provided text string will be configured on the object instance. state: description: - Configures the intended state of the instance of the object on the NIOS server. When this value is set to C(present), the object is configured on the device and when this value is set to C(absent) the value is removed (if necessary) from the device. default: present choices: - present - absent ''' EXAMPLES = ''' - name: configure a network ipv4 nios_network: network: 192.168.10.0/24 comment: this is a test comment state: present provider: host: "{{ inventory_hostname_short }}" username: admin password: admin connection: local - name: configure a network ipv6 nios_network: network: fe80::/64 comment: this is a test comment state: present provider: host: "{{ inventory_hostname_short }}" username: admin password: admin connection: local - name: set dhcp options for a network ipv4 nios_network: network: 192.168.10.0/24 comment: this is a test comment options: - name: domain-name value: ansible.com state: present provider: host: "{{ inventory_hostname_short }}" username: admin password: admin connection: local - name: remove a network ipv4 nios_network: network: 192.168.10.0/24 state: absent provider: host: "{{ inventory_hostname_short }}" username: admin password: admin connection: local ''' RETURN = ''' # ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six import iteritems from ansible.module_utils.net_tools.nios.api import WapiModule from ansible.module_utils.network.common.utils import validate_ip_address, validate_ip_v6_address from ansible.module_utils.net_tools.nios.api import NIOS_IPV4_NETWORK from ansible.module_utils.net_tools.nios.api import NIOS_IPV6_NETWORK def options(module): ''' Transforms the module argument into a valid WAPI struct This function will transform the options argument into a structure that is a valid WAPI structure in the format of: { name: <value>, num: <value>, value: <value>, use_option: <value>, vendor_class: <value> } It will remove any options that are set to None since WAPI will error on that condition. It will also verify that either `name` or `num` is set in the structure but does not validate the values are equal. The remainder of the value validation is performed by WAPI ''' options = list() for item in module.params['options']: opt = dict([(k, v) for k, v in iteritems(item) if v is not None]) if 'name' not in opt and 'num' not in opt: module.fail_json(msg='one of `name` or `num` is required for option value') options.append(opt) return options def check_ip_addr_type(ip): '''This function will check if the argument ip is type v4/v6 and return appropriate infoblox network type ''' check_ip = ip.split('/') if validate_ip_address(check_ip[0]): return NIOS_IPV4_NETWORK elif validate_ip_v6_address(check_ip[0]): return NIOS_IPV6_NETWORK def check_vendor_specific_dhcp_option(module, ib_spec): '''This function will check if the argument dhcp option belongs to vendor-specific and if yes then will remove use_options flag which is not supported with vendor-specific dhcp options. ''' for key, value in iteritems(ib_spec): if isinstance(module.params[key], list): temp_dict = module.params[key][0] if 'num' in temp_dict: if temp_dict['num'] in (43, 124, 125): del module.params[key][0]['use_option'] return ib_spec def main(): ''' Main entry point for module execution ''' option_spec = dict( # one of name or num is required; enforced by the function options() name=dict(), num=dict(type='int'), value=dict(required=True), use_option=dict(type='bool', default=True), vendor_class=dict(default='DHCP') ) ib_spec = dict( network=dict(required=True, aliases=['name', 'cidr'], ib_req=True), network_view=dict(default='default', ib_req=True), options=dict(type='list', elements='dict', options=option_spec, transform=options), extattrs=dict(type='dict'), comment=dict() ) argument_spec = dict( provider=dict(required=True), state=dict(default='present', choices=['present', 'absent']) ) argument_spec.update(ib_spec) argument_spec.update(WapiModule.provider_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) # to get the argument ipaddr obj_filter = dict([(k, module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')]) network_type = check_ip_addr_type(obj_filter['network']) wapi = WapiModule(module) # to check for vendor specific dhcp option ib_spec = check_vendor_specific_dhcp_option(module, ib_spec) result = wapi.run(network_type, ib_spec) module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 14894, 9572, 13002, 12, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 302, 9207, 63, 1200, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 2502, 26, 298, 8070, 351, 8360, 651, 71, 10641, 8593, 4239, 711, 2924, 199, 3612, 63, 1802, 26, 15453, 10332, 25913, 88, 653, 13532, 2784, 909, 199, 1802, 26, 523, 446, 15747, 436, 15, 269, 14185, 4454, 402, 2784, 2251, 687, 272, 10332, 25913, 88, 653, 13532, 8037, 14, 221, 961, 859, 31965, 653, 13532, 445, 8, 1200, 9, 2251, 272, 1808, 314, 10332, 25913, 88, 644, 3735, 3217, 1806, 14880, 14, 523, 446, 32090, 3865, 3531, 54, 20, 436, 3531, 54, 22, 21408, 19230, 199, 7538, 26, 523, 446, 2256, 25913, 88, 13, 1258, 199, 11036, 63, 9970, 63, 7677, 26, 302, 9207, 199, 1419, 26, 523, 2784, 26, 272, 1369, 26, 489, 446, 11015, 314, 2784, 370, 1050, 503, 2813, 687, 314, 2656, 14, 221, 710, 574, 267, 1077, 675, 29215, 15843, 14, 272, 1415, 26, 2549, 272, 5481, 26, 489, 446, 536, 489, 446, 16770, 523, 2784, 63, 1345, 26, 272, 1369, 26, 489, 446, 4094, 1482, 314, 536, 402, 314, 2784, 2455, 370, 20133, 543, 642, 267, 7526, 1256, 14, 272, 1415, 26, 2549, 272, 849, 26, 849, 523, 1511, 26, 272, 1369, 26, 489, 446, 4094, 1482, 314, 663, 402, 26821, 1511, 370, 506, 5120, 465, 1777, 402, 267, 314, 7526, 2784, 1256, 14, 221, 961, 1423, 11479, 282, 769, 267, 402, 1338, 334, 3239, 26265, 680, 221, 3979, 1101, 4039, 26265, 737, 267, 5210, 1373, 402, 445, 8, 354, 9, 503, 445, 8, 1507, 9, 1471, 506, 2013, 14, 272, 26265, 26, 489, 536, 26, 267, 1369, 26, 881, 446, 710, 536, 402, 314, 26821, 945, 370, 7908, 489, 1967, 26, 267, 1369, 26, 881, 446, 710, 1329, 402, 314, 26821, 945, 370, 7908, 489, 574, 26, 267, 1369, 26, 881, 446, 710, 574, 402, 314, 26821, 945, 2013, 701, 445, 8, 354, 9, 267, 1415, 26, 2549, 489, 675, 63, 1422, 26, 267, 1369, 26, 881, 446, 5972, 12966, 370, 282, 10026, 402, 1511, 334, 3239, 653, 13532, 3261, 3794, 9, 267, 730, 26, 2155, 267, 849, 26, 283, 5066, 7, 489, 20868, 63, 533, 26, 267, 1369, 26, 881, 446, 710, 536, 402, 314, 4601, 642, 26821, 945, 365, 4568, 370, 267, 849, 26, 26821, 523, 1599, 3288, 26, 272, 1369, 26, 489, 446, 22819, 367, 314, 2897, 402, 11524, 1164, 9382, 641, 314, 267, 1256, 402, 314, 909, 14, 221, 961, 1423, 11479, 282, 663, 402, 790, 1182, 574, 267, 6342, 367, 2897, 14, 523, 3721, 26, 272, 1369, 26, 489, 446, 4094, 1482, 282, 1318, 1059, 3721, 370, 506, 4568, 543, 314, 1256, 267, 402, 642, 909, 14, 221, 710, 2741, 1318, 1059, 911, 506, 7526, 641, 314, 267, 909, 1256, 14, 523, 1174, 26, 272, 1369, 26, 489, 446, 4094, 1482, 314, 11619, 1174, 402, 314, 1256, 402, 314, 909, 641, 267, 314, 653, 13532, 1654, 14, 221, 3979, 642, 574, 365, 663, 370, 445, 8, 1881, 395, 314, 909, 267, 365, 7526, 641, 314, 2243, 436, 1380, 642, 574, 365, 663, 370, 445, 8, 5575, 9, 267, 314, 574, 365, 4829, 334, 692, 5784, 9, 687, 314, 2243, 14, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 7908, 282, 2784, 3278, 20, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 13567, 14, 6568, 14, 709, 14, 16, 15, 1194, 272, 3721, 26, 642, 365, 282, 511, 3721, 272, 1174, 26, 3451, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 13, 536, 26, 7908, 282, 2784, 3278, 22, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 1964, 1257, 26346, 772, 272, 3721, 26, 642, 365, 282, 511, 3721, 272, 1174, 26, 3451, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 13, 536, 26, 663, 19064, 1511, 367, 282, 2784, 3278, 20, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 13567, 14, 6568, 14, 709, 14, 16, 15, 1194, 272, 3721, 26, 642, 365, 282, 511, 3721, 272, 1511, 26, 489, 446, 536, 26, 2881, 13, 354, 267, 574, 26, 3242, 14, 957, 272, 1174, 26, 3451, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 13, 536, 26, 2813, 282, 2784, 3278, 20, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 13567, 14, 6568, 14, 709, 14, 16, 15, 1194, 272, 1174, 26, 9552, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 2344, 199, 199, 9677, 275, 1449, 327, 1449, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 63, 2537, 14, 8445, 736, 14, 1246, 492, 644, 1246, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 4107, 63, 711, 63, 1562, 12, 4107, 63, 711, 63, 86, 22, 63, 1562, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 63, 2537, 14, 8445, 736, 14, 1246, 492, 653, 13532, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 14894, 9572, 13002, 12, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 302, 9207, 63, 1200, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 2502, 26, 298, 8070, 351, 8360, 651, 71, 10641, 8593, 4239, 711, 2924, 199, 3612, 63, 1802, 26, 15453, 10332, 25913, 88, 653, 13532, 2784, 909, 199, 1802, 26, 523, 446, 15747, 436, 15, 269, 14185, 4454, 402, 2784, 2251, 687, 272, 10332, 25913, 88, 653, 13532, 8037, 14, 221, 961, 859, 31965, 653, 13532, 445, 8, 1200, 9, 2251, 272, 1808, 314, 10332, 25913, 88, 644, 3735, 3217, 1806, 14880, 14, 523, 446, 32090, 3865, 3531, 54, 20, 436, 3531, 54, 22, 21408, 19230, 199, 7538, 26, 523, 446, 2256, 25913, 88, 13, 1258, 199, 11036, 63, 9970, 63, 7677, 26, 302, 9207, 199, 1419, 26, 523, 2784, 26, 272, 1369, 26, 489, 446, 11015, 314, 2784, 370, 1050, 503, 2813, 687, 314, 2656, 14, 221, 710, 574, 267, 1077, 675, 29215, 15843, 14, 272, 1415, 26, 2549, 272, 5481, 26, 489, 446, 536, 489, 446, 16770, 523, 2784, 63, 1345, 26, 272, 1369, 26, 489, 446, 4094, 1482, 314, 536, 402, 314, 2784, 2455, 370, 20133, 543, 642, 267, 7526, 1256, 14, 272, 1415, 26, 2549, 272, 849, 26, 849, 523, 1511, 26, 272, 1369, 26, 489, 446, 4094, 1482, 314, 663, 402, 26821, 1511, 370, 506, 5120, 465, 1777, 402, 267, 314, 7526, 2784, 1256, 14, 221, 961, 1423, 11479, 282, 769, 267, 402, 1338, 334, 3239, 26265, 680, 221, 3979, 1101, 4039, 26265, 737, 267, 5210, 1373, 402, 445, 8, 354, 9, 503, 445, 8, 1507, 9, 1471, 506, 2013, 14, 272, 26265, 26, 489, 536, 26, 267, 1369, 26, 881, 446, 710, 536, 402, 314, 26821, 945, 370, 7908, 489, 1967, 26, 267, 1369, 26, 881, 446, 710, 1329, 402, 314, 26821, 945, 370, 7908, 489, 574, 26, 267, 1369, 26, 881, 446, 710, 574, 402, 314, 26821, 945, 2013, 701, 445, 8, 354, 9, 267, 1415, 26, 2549, 489, 675, 63, 1422, 26, 267, 1369, 26, 881, 446, 5972, 12966, 370, 282, 10026, 402, 1511, 334, 3239, 653, 13532, 3261, 3794, 9, 267, 730, 26, 2155, 267, 849, 26, 283, 5066, 7, 489, 20868, 63, 533, 26, 267, 1369, 26, 881, 446, 710, 536, 402, 314, 4601, 642, 26821, 945, 365, 4568, 370, 267, 849, 26, 26821, 523, 1599, 3288, 26, 272, 1369, 26, 489, 446, 22819, 367, 314, 2897, 402, 11524, 1164, 9382, 641, 314, 267, 1256, 402, 314, 909, 14, 221, 961, 1423, 11479, 282, 663, 402, 790, 1182, 574, 267, 6342, 367, 2897, 14, 523, 3721, 26, 272, 1369, 26, 489, 446, 4094, 1482, 282, 1318, 1059, 3721, 370, 506, 4568, 543, 314, 1256, 267, 402, 642, 909, 14, 221, 710, 2741, 1318, 1059, 911, 506, 7526, 641, 314, 267, 909, 1256, 14, 523, 1174, 26, 272, 1369, 26, 489, 446, 4094, 1482, 314, 11619, 1174, 402, 314, 1256, 402, 314, 909, 641, 267, 314, 653, 13532, 1654, 14, 221, 3979, 642, 574, 365, 663, 370, 445, 8, 1881, 395, 314, 909, 267, 365, 7526, 641, 314, 2243, 436, 1380, 642, 574, 365, 663, 370, 445, 8, 5575, 9, 267, 314, 574, 365, 4829, 334, 692, 5784, 9, 687, 314, 2243, 14, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 3451, 489, 446, 9552, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 7908, 282, 2784, 3278, 20, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 13567, 14, 6568, 14, 709, 14, 16, 15, 1194, 272, 3721, 26, 642, 365, 282, 511, 3721, 272, 1174, 26, 3451, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 13, 536, 26, 7908, 282, 2784, 3278, 22, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 1964, 1257, 26346, 772, 272, 3721, 26, 642, 365, 282, 511, 3721, 272, 1174, 26, 3451, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 13, 536, 26, 663, 19064, 1511, 367, 282, 2784, 3278, 20, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 13567, 14, 6568, 14, 709, 14, 16, 15, 1194, 272, 3721, 26, 642, 365, 282, 511, 3721, 272, 1511, 26, 489, 446, 536, 26, 2881, 13, 354, 267, 574, 26, 3242, 14, 957, 272, 1174, 26, 3451, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 13, 536, 26, 2813, 282, 2784, 3278, 20, 523, 302, 9207, 63, 1200, 26, 272, 2784, 26, 13567, 14, 6568, 14, 709, 14, 16, 15, 1194, 272, 1174, 26, 9552, 272, 5022, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 63, 3612, 7820, 489, 3434, 26, 4628, 489, 2505, 26, 4628, 523, 1950, 26, 2257, 199, 2344, 199, 199, 9677, 275, 1449, 327, 1449, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 63, 2537, 14, 8445, 736, 14, 1246, 492, 644, 1246, 2377, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 1208, 492, 4107, 63, 711, 63, 1562, 12, 4107, 63, 711, 63, 86, 22, 63, 1562, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 63, 2537, 14, 8445, 736, 14, 1246, 492, 653, 13532, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
TeamEOS/kernel_htc_flounder
tools/perf/scripts/python/syscall-counts.py
11181
1522
# system call counts # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts.py [comm]\n"; for_comm = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): print "%-40s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
TeodorMihai/codecombat
scripts/analytics/mixpanelGetEvent.py
97
7517
# Get mixpanel event data via export API # Useful for debugging Mixpanel data weirdness targetLevels = ['dungeons-of-kithgard', 'the-raised-sword', 'endangered-burl'] targetLevels = ['dungeons-of-kithgard'] eventFunnel = ['Started Level', 'Saw Victory'] # eventFunnel = ['Saw Victory'] # eventFunnel = ['Started Level'] import sys from pprint import pprint from datetime import datetime, timedelta from mixpanel import Mixpanel try: import json except ImportError: import simplejson as json # NOTE: mixpanel dates are by day and inclusive # E.g. '2014-12-08' is any date that day, up to 2014-12-09 12am if __name__ == '__main__': if not len(sys.argv) is 3: print "Script format: <script> <api_key> <api_secret>" else: scriptStart = datetime.now() api_key = sys.argv[1] api_secret = sys.argv[2] api = Mixpanel( api_key = api_key, api_secret = api_secret ) startDate = '2015-01-01' endDate = '2015-01-26' startEvent = eventFunnel[0] endEvent = eventFunnel[-1] print("Requesting data for {0} to {1}".format(startDate, endDate)) data = api.request(['export'], { # 'where': '"539c630f30a67c3b05d98d95" == properties["id"]', # 'where': "('539c630f30a67c3b05d98d95' == properties['id'] or '539c630f30a67c3b05d98d95' == properties['distinct_id'])", 'event': eventFunnel, 'from_date': startDate, 'to_date': endDate }) weirdUserIDs = [] eventUsers = {} levelEventUserDayMap = {} levelUserEventDayMap = {} lines = data.split('\n') print "Received %d entries" % len(lines) for line in lines: try: if len(line) is 0: continue eventData = json.loads(line) # pprint(eventData) # break eventName = eventData['event'] if not eventName in eventFunnel: print 'Unexpected event ' + eventName break if not 'properties' in eventData: print('no properties, skpping') continue properties = eventData['properties'] if not 'distinct_id' in properties: print('no distinct_id, skpping') continue user = properties['distinct_id'] if not 'time' in properties: print('no time, skpping') continue time = properties['time'] pst = datetime.fromtimestamp(int(properties['time'])) utc = pst + timedelta(0, 8 * 60 * 60) dateCreated = utc.isoformat() day = dateCreated[0:10] if day < startDate or day > endDate: print "Skipping {0}".format(day) continue if 'levelID' in properties: level = properties['levelID'] elif 'level' in properties: level = properties['level'].lower().replace(' ', '-') else: print("Unkonwn level for", eventName) print(properties) break if not level in targetLevels: continue # if user != "539c630f30a67c3b05d98d95": continue pprint(eventData) # if user == "54c1fc3a08652d5305442c6b": # pprint(eventData) # break # if '-' in user: # weirdUserIDs.append(user) # # pprint(eventData) # # break # continue # print level if not level in levelEventUserDayMap: levelEventUserDayMap[level] = {} if not eventName in levelEventUserDayMap[level]: levelEventUserDayMap[level][eventName] = {} if not user in levelEventUserDayMap[level][eventName] or levelEventUserDayMap[level][eventName][user] > day: levelEventUserDayMap[level][eventName][user] = day if not user in eventUsers: eventUsers[user] = True if not level in levelUserEventDayMap: levelUserEventDayMap[level] = {} if not user in levelUserEventDayMap[level]: levelUserEventDayMap[level][user] = {} if not eventName in levelUserEventDayMap[level][user] or levelUserEventDayMap[level][user][eventName] > day: levelUserEventDayMap[level][user][eventName] = day except: print "Unexpected error:", sys.exc_info()[0] print line break # pprint(levelEventUserDayMap) print("Weird user IDs: {0}".format(len(weirdUserIDs))) for level in levelEventUserDayMap: for event in levelEventUserDayMap[level]: print("{0} {1} {2}".format(level, event, len(levelEventUserDayMap[level][event]))) print("Users: {0}".format(len(eventUsers))) noStartDayUsers = [] levelFunnelData = {} for level in levelUserEventDayMap: for user in levelUserEventDayMap[level]: # 6455 # for event in levelUserEventDayMap[level][user]: # day = levelUserEventDayMap[level][user][event] # if not level in levelFunnelData: levelFunnelData[level] = {} # if not day in levelFunnelData[level]: levelFunnelData[level][day] = {} # if not event in levelFunnelData[level][day]: levelFunnelData[level][day][event] = 0 # levelFunnelData[level][day][event] += 1 # 5382 funnelStartDay = None for event in levelUserEventDayMap[level][user]: day = levelUserEventDayMap[level][user][event] if not level in levelFunnelData: levelFunnelData[level] = {} if not day in levelFunnelData[level]: levelFunnelData[level][day] = {} if not event in levelFunnelData[level][day]: levelFunnelData[level][day][event] = 0 if eventFunnel[0] == event: levelFunnelData[level][day][event] += 1 funnelStartDay = day break if funnelStartDay: for event in levelUserEventDayMap[level][user]: if not event in levelFunnelData[level][funnelStartDay]: levelFunnelData[level][funnelStartDay][event] = 0 if eventFunnel[0] != event: levelFunnelData[level][funnelStartDay][event] += 1 for i in range(1, len(eventFunnel)): event = eventFunnel[i] if not event in levelFunnelData[level][funnelStartDay]: levelFunnelData[level][funnelStartDay][event] = 0 else: noStartDayUsers.append(user) pprint(levelFunnelData) print("No start day count: {0}".format(len(noStartDayUsers))) noStartDayUsers.sort() for i in range(len(noStartDayUsers)): if i > 50: break print(noStartDayUsers[i]) print("Script runtime: {0}".format(datetime.now() - scriptStart))
mit
[ 3, 2372, 13667, 7885, 1566, 666, 4799, 4843, 3261, 199, 3, 18491, 367, 10201, 603, 1148, 7885, 666, 22965, 4171, 199, 199, 1375, 4670, 83, 275, 788, 68, 16993, 4654, 13, 1618, 13, 75, 448, 71, 1005, 297, 283, 1589, 13, 21597, 13, 83, 1027, 297, 283, 500, 618, 581, 13, 66, 633, 418, 199, 1375, 4670, 83, 275, 788, 68, 16993, 4654, 13, 1618, 13, 75, 448, 71, 1005, 418, 199, 1430, 19941, 2715, 275, 788, 21031, 20400, 297, 283, 51, 10084, 6561, 1076, 418, 199, 3, 1566, 19941, 2715, 275, 788, 51, 10084, 6561, 1076, 418, 199, 3, 1566, 19941, 2715, 275, 788, 21031, 20400, 418, 199, 199, 646, 984, 199, 504, 10933, 492, 10933, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 13667, 7885, 492, 603, 1148, 7885, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 3, 6944, 26, 13667, 7885, 10831, 787, 701, 5382, 436, 20728, 199, 3, 662, 14, 71, 14, 283, 7280, 13, 713, 13, 2036, 7, 365, 1263, 1434, 626, 5382, 12, 1536, 370, 6927, 13, 713, 13, 1643, 3144, 455, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 440, 822, 8, 1274, 14, 3020, 9, 365, 650, 26, 267, 870, 298, 5229, 1475, 26, 665, 1579, 30, 665, 1246, 63, 498, 30, 665, 1246, 63, 4731, 4335, 272, 587, 26, 267, 2884, 3162, 275, 2197, 14, 2131, 342, 398, 2986, 63, 498, 275, 984, 14, 3020, 59, 17, 61, 267, 2986, 63, 4731, 275, 984, 14, 3020, 59, 18, 61, 267, 2986, 275, 603, 1148, 7885, 8, 288, 2986, 63, 498, 275, 2986, 63, 498, 12, 288, 2986, 63, 4731, 275, 2986, 63, 4731, 267, 776, 398, 1343, 2506, 275, 283, 7806, 13, 614, 13, 614, 7, 267, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1479, 7, 398, 1343, 2390, 275, 1566, 19941, 2715, 59, 16, 61, 267, 1284, 2390, 275, 1566, 19941, 2715, 1988, 17, 61, 398, 870, 480, 2017, 316, 666, 367, 469, 16, 93, 370, 469, 17, 5469, 908, 8, 928, 2506, 12, 1284, 2506, 430, 267, 666, 275, 2986, 14, 1069, 2941, 3790, 995, 469, 288, 327, 283, 4509, 356, 5522, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 2, 508, 4382, 905, 344, 23793, 288, 327, 283, 4509, 356, 16111, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 7, 508, 4382, 459, 344, 418, 503, 283, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 7, 508, 4382, 459, 12926, 63, 344, 1105, 401, 288, 283, 1430, 356, 1566, 19941, 2715, 12, 288, 283, 504, 63, 602, 356, 1343, 2506, 12, 288, 283, 475, 63, 602, 356, 1284, 2506, 267, 3828, 7318, 22965, 1899, 12818, 275, 942, 267, 1566, 12117, 275, 1052, 267, 2166, 2390, 1899, 12631, 2956, 275, 1052, 267, 2166, 1899, 2390, 12631, 2956, 275, 1052, 267, 2385, 275, 666, 14, 1294, 2258, 78, 358, 267, 870, 298, 9392, 450, 68, 4811, 2, 450, 822, 8, 1278, 9, 267, 367, 1004, 315, 2385, 26, 288, 862, 26, 355, 340, 822, 8, 604, 9, 365, 378, 26, 1980, 355, 1566, 1451, 275, 2022, 14, 3640, 8, 604, 9, 355, 327, 10933, 8, 1430, 1451, 9, 355, 327, 2059, 355, 1566, 985, 275, 1566, 1451, 459, 1430, 418, 355, 340, 440, 1566, 985, 315, 1566, 19941, 2715, 26, 490, 870, 283, 8708, 1566, 283, 435, 1566, 985, 490, 2059, 355, 340, 440, 283, 3282, 7, 315, 1566, 1451, 26, 490, 870, 360, 889, 4382, 12, 2386, 3637, 358, 490, 1980, 355, 4382, 275, 1566, 1451, 459, 3282, 418, 355, 340, 440, 283, 12926, 63, 344, 7, 315, 4382, 26, 490, 870, 360, 889, 15392, 63, 344, 12, 2386, 3637, 358, 490, 1980, 355, 922, 275, 4382, 459, 12926, 63, 344, 418, 355, 340, 440, 283, 521, 7, 315, 4382, 26, 490, 870, 360, 889, 900, 12, 2386, 3637, 358, 490, 1980, 355, 900, 275, 4382, 459, 521, 418, 355, 299, 270, 275, 2197, 14, 18531, 8, 442, 8, 3282, 459, 521, 5156, 355, 19314, 275, 299, 270, 435, 6871, 8, 16, 12, 1695, 627, 5212, 627, 5212, 9, 355, 1434, 10502, 275, 19314, 14, 17070, 342, 355, 5382, 275, 1434, 10502, 59, 16, 26, 709, 61, 355, 340, 5382, 665, 1343, 2506, 503, 5382, 690, 1284, 2506, 26, 490, 870, 298, 18297, 469, 16, 5469, 908, 8, 2977, 9, 490, 1980, 2234, 340, 283, 1896, 998, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 998, 418, 355, 916, 283, 1896, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 2278, 2325, 1252, 1814, 360, 1656, 26942, 355, 587, 26, 490, 870, 480, 1358, 75, 265, 3501, 2166, 367, 401, 1566, 985, 9, 490, 870, 8, 3282, 9, 490, 2059, 2234, 340, 440, 2166, 315, 1347, 4670, 83, 26, 1980, 2234, 327, 340, 922, 1137, 298, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 582, 1980, 355, 10933, 8, 1430, 1451, 9, 2234, 327, 340, 922, 508, 298, 1477, 67, 17, 3003, 19, 65, 29070, 2528, 68, 27030, 1477, 2260, 67, 22, 66, 582, 355, 327, 258, 10933, 8, 1430, 1451, 9, 355, 327, 258, 2059, 355, 327, 340, 10791, 315, 922, 26, 355, 327, 258, 22965, 1899, 12818, 14, 740, 8, 751, 9, 355, 327, 258, 327, 10933, 8, 1430, 1451, 9, 355, 327, 258, 327, 2059, 355, 327, 258, 1980, 2234, 327, 870, 2166, 2234, 340, 440, 2166, 315, 2166, 2390, 1899, 12631, 2956, 26, 2166, 2390, 1899, 12631, 2956, 59, 1896, 61, 275, 1052, 355, 340, 440, 1566, 985, 315, 2166, 2390, 1899, 12631, 2956, 59, 1896, 2189, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 61, 275, 1052, 355, 340, 440, 922, 315, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 61, 503, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 1527, 751, 61, 690, 5382, 26, 490, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 1527, 751, 61, 275 ]
[ 2372, 13667, 7885, 1566, 666, 4799, 4843, 3261, 199, 3, 18491, 367, 10201, 603, 1148, 7885, 666, 22965, 4171, 199, 199, 1375, 4670, 83, 275, 788, 68, 16993, 4654, 13, 1618, 13, 75, 448, 71, 1005, 297, 283, 1589, 13, 21597, 13, 83, 1027, 297, 283, 500, 618, 581, 13, 66, 633, 418, 199, 1375, 4670, 83, 275, 788, 68, 16993, 4654, 13, 1618, 13, 75, 448, 71, 1005, 418, 199, 1430, 19941, 2715, 275, 788, 21031, 20400, 297, 283, 51, 10084, 6561, 1076, 418, 199, 3, 1566, 19941, 2715, 275, 788, 51, 10084, 6561, 1076, 418, 199, 3, 1566, 19941, 2715, 275, 788, 21031, 20400, 418, 199, 199, 646, 984, 199, 504, 10933, 492, 10933, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 13667, 7885, 492, 603, 1148, 7885, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 3, 6944, 26, 13667, 7885, 10831, 787, 701, 5382, 436, 20728, 199, 3, 662, 14, 71, 14, 283, 7280, 13, 713, 13, 2036, 7, 365, 1263, 1434, 626, 5382, 12, 1536, 370, 6927, 13, 713, 13, 1643, 3144, 455, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 440, 822, 8, 1274, 14, 3020, 9, 365, 650, 26, 267, 870, 298, 5229, 1475, 26, 665, 1579, 30, 665, 1246, 63, 498, 30, 665, 1246, 63, 4731, 4335, 272, 587, 26, 267, 2884, 3162, 275, 2197, 14, 2131, 342, 398, 2986, 63, 498, 275, 984, 14, 3020, 59, 17, 61, 267, 2986, 63, 4731, 275, 984, 14, 3020, 59, 18, 61, 267, 2986, 275, 603, 1148, 7885, 8, 288, 2986, 63, 498, 275, 2986, 63, 498, 12, 288, 2986, 63, 4731, 275, 2986, 63, 4731, 267, 776, 398, 1343, 2506, 275, 283, 7806, 13, 614, 13, 614, 7, 267, 1284, 2506, 275, 283, 7806, 13, 614, 13, 1479, 7, 398, 1343, 2390, 275, 1566, 19941, 2715, 59, 16, 61, 267, 1284, 2390, 275, 1566, 19941, 2715, 1988, 17, 61, 398, 870, 480, 2017, 316, 666, 367, 469, 16, 93, 370, 469, 17, 5469, 908, 8, 928, 2506, 12, 1284, 2506, 430, 267, 666, 275, 2986, 14, 1069, 2941, 3790, 995, 469, 288, 327, 283, 4509, 356, 5522, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 2, 508, 4382, 905, 344, 23793, 288, 327, 283, 4509, 356, 16111, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 7, 508, 4382, 459, 344, 418, 503, 283, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 7, 508, 4382, 459, 12926, 63, 344, 1105, 401, 288, 283, 1430, 356, 1566, 19941, 2715, 12, 288, 283, 504, 63, 602, 356, 1343, 2506, 12, 288, 283, 475, 63, 602, 356, 1284, 2506, 267, 3828, 7318, 22965, 1899, 12818, 275, 942, 267, 1566, 12117, 275, 1052, 267, 2166, 2390, 1899, 12631, 2956, 275, 1052, 267, 2166, 1899, 2390, 12631, 2956, 275, 1052, 267, 2385, 275, 666, 14, 1294, 2258, 78, 358, 267, 870, 298, 9392, 450, 68, 4811, 2, 450, 822, 8, 1278, 9, 267, 367, 1004, 315, 2385, 26, 288, 862, 26, 355, 340, 822, 8, 604, 9, 365, 378, 26, 1980, 355, 1566, 1451, 275, 2022, 14, 3640, 8, 604, 9, 355, 327, 10933, 8, 1430, 1451, 9, 355, 327, 2059, 355, 1566, 985, 275, 1566, 1451, 459, 1430, 418, 355, 340, 440, 1566, 985, 315, 1566, 19941, 2715, 26, 490, 870, 283, 8708, 1566, 283, 435, 1566, 985, 490, 2059, 355, 340, 440, 283, 3282, 7, 315, 1566, 1451, 26, 490, 870, 360, 889, 4382, 12, 2386, 3637, 358, 490, 1980, 355, 4382, 275, 1566, 1451, 459, 3282, 418, 355, 340, 440, 283, 12926, 63, 344, 7, 315, 4382, 26, 490, 870, 360, 889, 15392, 63, 344, 12, 2386, 3637, 358, 490, 1980, 355, 922, 275, 4382, 459, 12926, 63, 344, 418, 355, 340, 440, 283, 521, 7, 315, 4382, 26, 490, 870, 360, 889, 900, 12, 2386, 3637, 358, 490, 1980, 355, 900, 275, 4382, 459, 521, 418, 355, 299, 270, 275, 2197, 14, 18531, 8, 442, 8, 3282, 459, 521, 5156, 355, 19314, 275, 299, 270, 435, 6871, 8, 16, 12, 1695, 627, 5212, 627, 5212, 9, 355, 1434, 10502, 275, 19314, 14, 17070, 342, 355, 5382, 275, 1434, 10502, 59, 16, 26, 709, 61, 355, 340, 5382, 665, 1343, 2506, 503, 5382, 690, 1284, 2506, 26, 490, 870, 298, 18297, 469, 16, 5469, 908, 8, 2977, 9, 490, 1980, 2234, 340, 283, 1896, 998, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 998, 418, 355, 916, 283, 1896, 7, 315, 4382, 26, 490, 2166, 275, 4382, 459, 1896, 2278, 2325, 1252, 1814, 360, 1656, 26942, 355, 587, 26, 490, 870, 480, 1358, 75, 265, 3501, 2166, 367, 401, 1566, 985, 9, 490, 870, 8, 3282, 9, 490, 2059, 2234, 340, 440, 2166, 315, 1347, 4670, 83, 26, 1980, 2234, 327, 340, 922, 1137, 298, 25391, 67, 22, 1216, 70, 1216, 65, 1822, 67, 19, 66, 1717, 68, 2905, 68, 2720, 582, 1980, 355, 10933, 8, 1430, 1451, 9, 2234, 327, 340, 922, 508, 298, 1477, 67, 17, 3003, 19, 65, 29070, 2528, 68, 27030, 1477, 2260, 67, 22, 66, 582, 355, 327, 258, 10933, 8, 1430, 1451, 9, 355, 327, 258, 2059, 355, 327, 340, 10791, 315, 922, 26, 355, 327, 258, 22965, 1899, 12818, 14, 740, 8, 751, 9, 355, 327, 258, 327, 10933, 8, 1430, 1451, 9, 355, 327, 258, 327, 2059, 355, 327, 258, 1980, 2234, 327, 870, 2166, 2234, 340, 440, 2166, 315, 2166, 2390, 1899, 12631, 2956, 26, 2166, 2390, 1899, 12631, 2956, 59, 1896, 61, 275, 1052, 355, 340, 440, 1566, 985, 315, 2166, 2390, 1899, 12631, 2956, 59, 1896, 2189, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 61, 275, 1052, 355, 340, 440, 922, 315, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 61, 503, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 1527, 751, 61, 690, 5382, 26, 490, 2166, 2390, 1899, 12631, 2956, 59, 1896, 1527, 1430, 985, 1527, 751, 61, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ryano144/intellij-community
python/lib/Lib/modjy/modjy_response.py
109
4424
### # # Copyright Alan Kennedy. # # You may contact the copyright holder at this uri: # # http://www.xhaus.com/contact/modjy # # The licence under which this code is released is the Apache License v2.0. # # The terms and conditions of this license are listed in a file contained # in the distribution that also contained this file, under the name # LICENSE.txt. # # You may also read a copy of the license at the following web address. # # http://modjy.xhaus.com/LICENSE.txt # ### import types from java.lang import System from modjy_exceptions import * from modjy_write import write_object # From: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.1 hop_by_hop_headers = { 'connection': None, 'keep-alive': None, 'proxy-authenticate': None, 'proxy-authorization': None, 'te': None, 'trailers': None, 'transfer-encoding': None, 'upgrade': None, } class start_response_object: def __init__(self, req, resp): self.http_req = req self.http_resp = resp self.write_callable = None self.called = 0 self.content_length = None # I'm doing the parameters this way to facilitate porting back to java def __call__(self, *args, **keywords): if len(args) < 2 or len(args) > 3: raise BadArgument("Start response callback requires either two or three arguments: got %s" % str(args)) if len(args) == 3: exc_info = args[2] try: try: self.http_resp.reset() except IllegalStateException, isx: raise exc_info[0], exc_info[1], exc_info[2] finally: exc_info = None else: if self.called > 0: raise StartResponseCalledTwice("Start response callback may only be called once, without exception information.") status_str = args[0] headers_list = args[1] if not isinstance(status_str, types.StringType): raise BadArgument("Start response callback requires string as first argument") if not isinstance(headers_list, types.ListType): raise BadArgument("Start response callback requires list as second argument") try: status_code, status_message_str = status_str.split(" ", 1) self.http_resp.setStatus(int(status_code)) except ValueError: raise BadArgument("Status string must be of the form '<int> <string>'") self.make_write_object() try: for header_name, header_value in headers_list: header_name_lower = header_name.lower() if hop_by_hop_headers.has_key(header_name_lower): raise HopByHopHeaderSet("Under WSGI, it is illegal to set hop-by-hop headers, i.e. '%s'" % header_name) if header_name_lower == "content-length": try: self.set_content_length(int(header_value)) except ValueError, v: raise BadArgument("Content-Length header value must be a string containing an integer, not '%s'" % header_value) else: final_value = header_value.encode('latin-1') # Here would be the place to check for control characters, whitespace, etc self.http_resp.addHeader(header_name, final_value) except (AttributeError, TypeError), t: raise BadArgument("Start response callback headers must contain a list of (<string>,<string>) tuples") except UnicodeError, u: raise BadArgument("Encoding error: header values may only contain latin-1 characters, not '%s'" % repr(header_value)) except ValueError, v: raise BadArgument("Headers list must contain 2-tuples") self.called += 1 return self.write_callable def set_content_length(self, length): if self.write_callable.num_writes == 0: self.content_length = length self.http_resp.setContentLength(length) else: raise ResponseCommitted("Cannot set content-length: response is already commited.") def make_write_object(self): try: self.write_callable = write_object(self.http_resp.getOutputStream()) except IOException, iox: raise IOError(iox) return self.write_callable
apache-2.0
[ 5680, 199, 3, 199, 3, 1898, 437, 1502, 1804, 287, 7439, 89, 14, 221, 199, 3, 221, 199, 3, 2047, 1443, 8966, 314, 4248, 16712, 737, 642, 5108, 26, 199, 3, 221, 199, 3, 1455, 921, 1544, 14, 88, 2411, 527, 14, 957, 15, 7811, 15, 1494, 24589, 199, 3, 221, 199, 3, 710, 23854, 4894, 1334, 1314, 642, 1233, 365, 14286, 365, 314, 3668, 844, 373, 18, 14, 16, 14, 199, 3, 221, 199, 3, 710, 2895, 436, 3704, 402, 642, 4190, 787, 10532, 315, 282, 570, 10470, 199, 3, 315, 314, 4084, 626, 2597, 10470, 642, 570, 12, 1334, 314, 536, 199, 3, 5113, 14, 2424, 14, 199, 3, 221, 199, 3, 2047, 1443, 2597, 1586, 282, 1331, 402, 314, 4190, 737, 314, 2569, 3330, 2287, 14, 199, 3, 221, 199, 3, 1455, 921, 1494, 24589, 14, 88, 2411, 527, 14, 957, 15, 3961, 14, 2424, 199, 3, 199, 5680, 199, 199, 646, 2943, 199, 199, 504, 12120, 14, 4159, 492, 6187, 199, 199, 504, 3413, 24589, 63, 3924, 492, 627, 199, 504, 3413, 24589, 63, 952, 492, 2218, 63, 785, 199, 199, 3, 11606, 26, 1455, 921, 1544, 14, 87, 19, 14, 1308, 15, 8548, 4574, 15, 8973, 25807, 15, 8973, 25807, 13, 3321, 969, 14, 1360, 3, 3321, 969, 14, 21, 14, 17, 199, 199, 13376, 63, 991, 63, 13376, 63, 2139, 275, 469, 272, 283, 2105, 356, 488, 12, 272, 283, 3250, 13, 9631, 356, 488, 12, 272, 283, 3280, 13, 13975, 356, 488, 12, 272, 283, 3280, 13, 15846, 356, 488, 12, 272, 283, 266, 356, 488, 12, 272, 283, 1239, 441, 2393, 356, 488, 12, 272, 283, 9609, 13, 2991, 356, 488, 12, 272, 283, 9375, 356, 488, 12, 199, 93, 199, 199, 533, 1343, 63, 1310, 63, 785, 26, 339, 347, 636, 826, 721, 277, 12, 2648, 12, 3085, 304, 267, 291, 14, 1014, 63, 2103, 275, 2648, 267, 291, 14, 1014, 63, 4518, 275, 3085, 267, 291, 14, 952, 63, 8296, 275, 488, 267, 291, 14, 3527, 275, 378, 267, 291, 14, 1317, 63, 1267, 275, 488, 339, 327, 473, 6704, 9689, 314, 2633, 642, 4340, 370, 30242, 1051, 323, 1844, 316, 1771, 370, 12120, 272, 347, 636, 1250, 721, 277, 12, 627, 589, 12, 1011, 7511, 304, 267, 340, 822, 8, 589, 9, 665, 499, 503, 822, 8, 589, 9, 690, 650, 26, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 5074, 1902, 2877, 503, 7795, 2368, 26, 4788, 450, 83, 2, 450, 620, 8, 589, 430, 267, 340, 822, 8, 589, 9, 508, 650, 26, 288, 3178, 63, 815, 275, 1249, 59, 18, 61, 288, 862, 26, 355, 862, 26, 490, 291, 14, 1014, 63, 4518, 14, 3958, 342, 355, 871, 473, 13486, 2223, 1726, 12, 365, 88, 26, 490, 746, 3178, 63, 815, 59, 16, 467, 3178, 63, 815, 59, 17, 467, 3178, 63, 815, 59, 18, 61, 288, 3753, 26, 355, 3178, 63, 815, 275, 488, 267, 587, 26, 288, 340, 291, 14, 3527, 690, 378, 26, 355, 746, 7707, 2364, 10474, 22879, 1885, 480, 3162, 1177, 3233, 1443, 1454, 506, 2797, 5403, 12, 1928, 1919, 2556, 2685, 267, 2004, 63, 495, 275, 1249, 59, 16, 61, 267, 2323, 63, 513, 275, 1249, 59, 17, 61, 267, 340, 440, 1228, 8, 1205, 63, 495, 12, 2943, 14, 22463, 304, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 5074, 1059, 465, 1642, 1423, 531, 267, 340, 440, 1228, 8, 2139, 63, 513, 12, 2943, 14, 22113, 304, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 5074, 769, 465, 3499, 1423, 531, 267, 862, 26, 288, 2004, 63, 600, 12, 2004, 63, 1188, 63, 495, 275, 2004, 63, 495, 14, 1294, 480, 3872, 413, 9, 288, 291, 14, 1014, 63, 4518, 14, 409, 3694, 8, 442, 8, 1205, 63, 600, 430, 267, 871, 1722, 26, 288, 746, 8857, 5201, 480, 3694, 1059, 1471, 506, 402, 314, 1824, 2650, 442, 30, 665, 875, 3524, 531, 267, 291, 14, 1875, 63, 952, 63, 785, 342, 267, 862, 26, 288, 367, 1406, 63, 354, 12, 1406, 63, 585, 315, 2323, 63, 513, 26, 355, 1406, 63, 354, 63, 2325, 275, 1406, 63, 354, 14, 2325, 342, 355, 340, 22377, 63, 991, 63, 13376, 63, 2139, 14, 1989, 63, 498, 8, 1291, 63, 354, 63, 2325, 304, 490, 746, 869, 411, 2175, 13378, 2567, 1084, 480, 16001, 9279, 12, 652, 365, 20282, 370, 663, 22377, 13, 991, 13, 13376, 2323, 12, 284, 14, 69, 14, 1543, 83, 4065, 450, 1406, 63, 354, 9, 355, 340, 1406, 63, 354, 63, 2325, 508, 298, 1317, 13, 1267, 582, 490, 862, 26, 717, 291, 14, 409, 63, 1317, 63, 1267, 8, 442, 8, 1291, 63, 585, 430, 490, 871, 1722, 12, 373, 26, 717, 746, 8857, 5201, 480, 2714, 13, 4625, 1406, 574, 1471, 506, 282, 1059, 3035, 376, 3000, 12, 440, 1543, 83, 4065, 450, 1406, 63, 585, 9, 355, 587, 26, 490, 4242, 63, 585, 275, 1406, 63, 585, 14, 2143, 360, 10378, 13, 17, 358, 490, 327, 11842, 3955, 506, 314, 4192, 370, 1104, 367, 3304, 4110, 12, 8139, 12, 5423, 490, 291, 14, 1014, 63, 4518, 14, 525, 2567, 8, 1291, 63, 354, 12, 4242, 63, 585, 9, 267, 871, 334, 10227, 12, 3146, 395, 307, 26, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 2323, 1471, 1395, 282, 769, 402, 8642, 875, 32659, 875, 18956, 6346, 531, 267, 871, 20872, 12, 399, 26, 288, 746, 8857, 5201, 480, 7630, 1125, 26, 1406, 1338, 1443, 1454, 1395, 16899, 13, 17, 4110, 12, 440, 1543, 83, 4065, 450, 4700, 8, 1291, 63, 585, 430, 267, 871, 1722, 12, 373, 26, 288, 746, 8857, 5201, 480, 9883, 769, 1471, 1395, 499, 13, 11760, 531, 267, 291, 14, 3527, 847, 413, 267, 372, 291, 14, 952, 63, 8296, 339, 347, 663, 63, 1317, 63, 1267, 8, 277, 12, 2582, 304, 267, 340, 291, 14, 952, 63, 8296, 14, 1507, 63, 16334, 508, 378, 26, 288, 291, 14, 1317, 63, 1267, 275, 2582, 288, 291, 14, 1014, 63, 4518, 14, 28680, 4625, 8, 1267, 9, 267, 587, 26, 288, 746, 7232, 11421, 471, 480, 6612, 663, 1564, 13, 1267, 26 ]
[ 199, 3, 199, 3, 1898, 437, 1502, 1804, 287, 7439, 89, 14, 221, 199, 3, 221, 199, 3, 2047, 1443, 8966, 314, 4248, 16712, 737, 642, 5108, 26, 199, 3, 221, 199, 3, 1455, 921, 1544, 14, 88, 2411, 527, 14, 957, 15, 7811, 15, 1494, 24589, 199, 3, 221, 199, 3, 710, 23854, 4894, 1334, 1314, 642, 1233, 365, 14286, 365, 314, 3668, 844, 373, 18, 14, 16, 14, 199, 3, 221, 199, 3, 710, 2895, 436, 3704, 402, 642, 4190, 787, 10532, 315, 282, 570, 10470, 199, 3, 315, 314, 4084, 626, 2597, 10470, 642, 570, 12, 1334, 314, 536, 199, 3, 5113, 14, 2424, 14, 199, 3, 221, 199, 3, 2047, 1443, 2597, 1586, 282, 1331, 402, 314, 4190, 737, 314, 2569, 3330, 2287, 14, 199, 3, 221, 199, 3, 1455, 921, 1494, 24589, 14, 88, 2411, 527, 14, 957, 15, 3961, 14, 2424, 199, 3, 199, 5680, 199, 199, 646, 2943, 199, 199, 504, 12120, 14, 4159, 492, 6187, 199, 199, 504, 3413, 24589, 63, 3924, 492, 627, 199, 504, 3413, 24589, 63, 952, 492, 2218, 63, 785, 199, 199, 3, 11606, 26, 1455, 921, 1544, 14, 87, 19, 14, 1308, 15, 8548, 4574, 15, 8973, 25807, 15, 8973, 25807, 13, 3321, 969, 14, 1360, 3, 3321, 969, 14, 21, 14, 17, 199, 199, 13376, 63, 991, 63, 13376, 63, 2139, 275, 469, 272, 283, 2105, 356, 488, 12, 272, 283, 3250, 13, 9631, 356, 488, 12, 272, 283, 3280, 13, 13975, 356, 488, 12, 272, 283, 3280, 13, 15846, 356, 488, 12, 272, 283, 266, 356, 488, 12, 272, 283, 1239, 441, 2393, 356, 488, 12, 272, 283, 9609, 13, 2991, 356, 488, 12, 272, 283, 9375, 356, 488, 12, 199, 93, 199, 199, 533, 1343, 63, 1310, 63, 785, 26, 339, 347, 636, 826, 721, 277, 12, 2648, 12, 3085, 304, 267, 291, 14, 1014, 63, 2103, 275, 2648, 267, 291, 14, 1014, 63, 4518, 275, 3085, 267, 291, 14, 952, 63, 8296, 275, 488, 267, 291, 14, 3527, 275, 378, 267, 291, 14, 1317, 63, 1267, 275, 488, 339, 327, 473, 6704, 9689, 314, 2633, 642, 4340, 370, 30242, 1051, 323, 1844, 316, 1771, 370, 12120, 272, 347, 636, 1250, 721, 277, 12, 627, 589, 12, 1011, 7511, 304, 267, 340, 822, 8, 589, 9, 665, 499, 503, 822, 8, 589, 9, 690, 650, 26, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 5074, 1902, 2877, 503, 7795, 2368, 26, 4788, 450, 83, 2, 450, 620, 8, 589, 430, 267, 340, 822, 8, 589, 9, 508, 650, 26, 288, 3178, 63, 815, 275, 1249, 59, 18, 61, 288, 862, 26, 355, 862, 26, 490, 291, 14, 1014, 63, 4518, 14, 3958, 342, 355, 871, 473, 13486, 2223, 1726, 12, 365, 88, 26, 490, 746, 3178, 63, 815, 59, 16, 467, 3178, 63, 815, 59, 17, 467, 3178, 63, 815, 59, 18, 61, 288, 3753, 26, 355, 3178, 63, 815, 275, 488, 267, 587, 26, 288, 340, 291, 14, 3527, 690, 378, 26, 355, 746, 7707, 2364, 10474, 22879, 1885, 480, 3162, 1177, 3233, 1443, 1454, 506, 2797, 5403, 12, 1928, 1919, 2556, 2685, 267, 2004, 63, 495, 275, 1249, 59, 16, 61, 267, 2323, 63, 513, 275, 1249, 59, 17, 61, 267, 340, 440, 1228, 8, 1205, 63, 495, 12, 2943, 14, 22463, 304, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 5074, 1059, 465, 1642, 1423, 531, 267, 340, 440, 1228, 8, 2139, 63, 513, 12, 2943, 14, 22113, 304, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 5074, 769, 465, 3499, 1423, 531, 267, 862, 26, 288, 2004, 63, 600, 12, 2004, 63, 1188, 63, 495, 275, 2004, 63, 495, 14, 1294, 480, 3872, 413, 9, 288, 291, 14, 1014, 63, 4518, 14, 409, 3694, 8, 442, 8, 1205, 63, 600, 430, 267, 871, 1722, 26, 288, 746, 8857, 5201, 480, 3694, 1059, 1471, 506, 402, 314, 1824, 2650, 442, 30, 665, 875, 3524, 531, 267, 291, 14, 1875, 63, 952, 63, 785, 342, 267, 862, 26, 288, 367, 1406, 63, 354, 12, 1406, 63, 585, 315, 2323, 63, 513, 26, 355, 1406, 63, 354, 63, 2325, 275, 1406, 63, 354, 14, 2325, 342, 355, 340, 22377, 63, 991, 63, 13376, 63, 2139, 14, 1989, 63, 498, 8, 1291, 63, 354, 63, 2325, 304, 490, 746, 869, 411, 2175, 13378, 2567, 1084, 480, 16001, 9279, 12, 652, 365, 20282, 370, 663, 22377, 13, 991, 13, 13376, 2323, 12, 284, 14, 69, 14, 1543, 83, 4065, 450, 1406, 63, 354, 9, 355, 340, 1406, 63, 354, 63, 2325, 508, 298, 1317, 13, 1267, 582, 490, 862, 26, 717, 291, 14, 409, 63, 1317, 63, 1267, 8, 442, 8, 1291, 63, 585, 430, 490, 871, 1722, 12, 373, 26, 717, 746, 8857, 5201, 480, 2714, 13, 4625, 1406, 574, 1471, 506, 282, 1059, 3035, 376, 3000, 12, 440, 1543, 83, 4065, 450, 1406, 63, 585, 9, 355, 587, 26, 490, 4242, 63, 585, 275, 1406, 63, 585, 14, 2143, 360, 10378, 13, 17, 358, 490, 327, 11842, 3955, 506, 314, 4192, 370, 1104, 367, 3304, 4110, 12, 8139, 12, 5423, 490, 291, 14, 1014, 63, 4518, 14, 525, 2567, 8, 1291, 63, 354, 12, 4242, 63, 585, 9, 267, 871, 334, 10227, 12, 3146, 395, 307, 26, 288, 746, 8857, 5201, 480, 3162, 1177, 3233, 2323, 1471, 1395, 282, 769, 402, 8642, 875, 32659, 875, 18956, 6346, 531, 267, 871, 20872, 12, 399, 26, 288, 746, 8857, 5201, 480, 7630, 1125, 26, 1406, 1338, 1443, 1454, 1395, 16899, 13, 17, 4110, 12, 440, 1543, 83, 4065, 450, 4700, 8, 1291, 63, 585, 430, 267, 871, 1722, 12, 373, 26, 288, 746, 8857, 5201, 480, 9883, 769, 1471, 1395, 499, 13, 11760, 531, 267, 291, 14, 3527, 847, 413, 267, 372, 291, 14, 952, 63, 8296, 339, 347, 663, 63, 1317, 63, 1267, 8, 277, 12, 2582, 304, 267, 340, 291, 14, 952, 63, 8296, 14, 1507, 63, 16334, 508, 378, 26, 288, 291, 14, 1317, 63, 1267, 275, 2582, 288, 291, 14, 1014, 63, 4518, 14, 28680, 4625, 8, 1267, 9, 267, 587, 26, 288, 746, 7232, 11421, 471, 480, 6612, 663, 1564, 13, 1267, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MattAllmendinger/coala
tests/bearlib/languages/documentation/DocstyleDefinitionTest.py
22
2695
import unittest from coalib.bearlib.languages.documentation.DocstyleDefinition import ( DocstyleDefinition) class DocstyleDefinitionTest(unittest.TestCase): def test_fail_instantation(self): with self.assertRaises(ValueError): DocstyleDefinition("PYTHON", "doxyGEN", (("##", "#"),)) with self.assertRaises(ValueError): DocstyleDefinition("WEIRD-PY", "schloxygen", (("##+", "x", "y", "z"),)) with self.assertRaises(ValueError): DocstyleDefinition("PYTHON", "doxygen", (("##", "", "#"), ('"""', '"""'))) with self.assertRaises(TypeError): DocstyleDefinition(123, ["doxygen"], (('"""', '"""'))) def test_properties(self): uut = DocstyleDefinition("C", "doxygen", (("/**", "*", "*/"),)) self.assertEqual(uut.language, "c") self.assertEqual(uut.docstyle, "doxygen") self.assertEqual(uut.markers, (("/**", "*", "*/"),)) uut = DocstyleDefinition("PYTHON", "doxyGEN", [("##", "", "#")]) self.assertEqual(uut.language, "python") self.assertEqual(uut.docstyle, "doxygen") self.assertEqual(uut.markers, (("##", "", "#"),)) uut = DocstyleDefinition("I2C", "my-custom-tool", (["~~", "/~", "/~"], (">!", ">>", ">>"))) self.assertEqual(uut.language, "i2c") self.assertEqual(uut.docstyle, "my-custom-tool") self.assertEqual(uut.markers, (("~~", "/~", "/~"), (">!", ">>", ">>"))) uut = DocstyleDefinition("Cpp", "doxygen", ("~~", "/~", "/~")) self.assertEqual(uut.language, "cpp") self.assertEqual(uut.docstyle, "doxygen") self.assertEqual(uut.markers, (("~~", "/~", "/~"),)) def test_load(self): # Test unregistered docstyle. with self.assertRaises(FileNotFoundError): next(DocstyleDefinition.load("PYTHON", "INVALID")) # Test unregistered language in existing docstyle. with self.assertRaises(KeyError): next(DocstyleDefinition.load("bake-a-cake", "default")) # Test wrong argument type. with self.assertRaises(TypeError): next(DocstyleDefinition.load(123, ["list"])) # Test python 3 default configuration and if everything is parsed # right. result = DocstyleDefinition.load("PYTHON3", "default") self.assertEqual(result.language, "python3") self.assertEqual(result.docstyle, "default") self.assertEqual(result.markers, (('"""', '', '"""'),))
agpl-3.0
[ 646, 2882, 199, 199, 504, 512, 25530, 14, 31796, 773, 14, 13209, 14, 9970, 14, 3768, 2487, 10701, 492, 334, 272, 5454, 2487, 10701, 9, 421, 199, 533, 5454, 2487, 10701, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1633, 63, 3615, 867, 425, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 5454, 2487, 10701, 480, 11720, 401, 298, 1117, 1702, 9289, 401, 19110, 309, 401, 5426, 1288, 430, 398, 543, 291, 14, 1855, 8, 3393, 304, 288, 5454, 2487, 10701, 480, 5408, 3927, 36, 13, 4521, 401, 3044, 298, 15820, 320, 20515, 401, 3044, 19110, 309, 22758, 298, 88, 401, 298, 89, 401, 298, 90, 1288, 430, 398, 543, 291, 14, 1855, 8, 3393, 304, 288, 5454, 2487, 10701, 480, 11720, 401, 3044, 298, 1117, 20515, 401, 3044, 19110, 309, 401, 4873, 5426, 1288, 661, 624, 297, 283, 624, 7058, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 5454, 2487, 10701, 8, 4288, 12, 2097, 1117, 20515, 2255, 13636, 624, 297, 283, 624, 7058, 339, 347, 511, 63, 3282, 8, 277, 304, 267, 399, 337, 275, 5454, 2487, 10701, 480, 35, 401, 298, 1117, 20515, 401, 334, 4769, 538, 401, 8969, 401, 8969, 15, 1288, 430, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 67, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1117, 20515, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 334, 4769, 538, 401, 8969, 401, 8969, 15, 1288, 430, 398, 399, 337, 275, 5454, 2487, 10701, 480, 11720, 401, 298, 1117, 1702, 9289, 401, 10003, 309, 401, 4873, 5426, 13403, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 1548, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1117, 20515, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 19110, 309, 401, 4873, 5426, 1288, 430, 398, 399, 337, 275, 5454, 2487, 10701, 480, 41, 18, 35, 401, 639, 298, 1662, 13, 4229, 13, 3557, 401, 639, 334, 905, 1714, 401, 3286, 94, 401, 3286, 94, 2255, 1689, 30, 17716, 298, 1140, 401, 298, 1140, 13324, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 73, 18, 67, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1662, 13, 4229, 13, 3557, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 19110, 1714, 401, 3286, 94, 401, 3286, 94, 1288, 1689, 30, 17716, 298, 1140, 401, 298, 1140, 13324, 398, 399, 337, 275, 5454, 2487, 10701, 480, 19705, 401, 298, 1117, 20515, 401, 1689, 1714, 401, 3286, 94, 401, 3286, 94, 2237, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 5910, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1117, 20515, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 19110, 1714, 401, 3286, 94, 401, 3286, 94, 1288, 430, 339, 347, 511, 63, 912, 8, 277, 304, 267, 327, 1379, 625, 11616, 1382, 2487, 14, 267, 543, 291, 14, 1855, 8, 1173, 10870, 304, 288, 2163, 8, 3768, 2487, 10701, 14, 912, 480, 11720, 401, 298, 9692, 2237, 398, 327, 1379, 625, 11616, 2637, 315, 3411, 1382, 2487, 14, 267, 543, 291, 14, 1855, 8, 10230, 304, 288, 2163, 8, 3768, 2487, 10701, 14, 912, 480, 66, 1728, 13, 65, 13, 696, 415, 401, 298, 885, 2237, 398, 327, 1379, 6835, 1423, 730, 14, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 2163, 8, 3768, 2487, 10701, 14, 912, 8, 4288, 12, 2097, 513, 13045, 398, 327, 1379, 2366, 650, 849, 2897, 436, 340, 8137, 365, 4565, 267, 327, 2451, 14, 267, 754, 275, 5454, 2487, 10701, 14, 912, 480, 11720, 19, 401, 298, 885, 531, 398, 291, 14, 629, 8, 1099, 14, 3671, 12, 298, 1548, 19, 531, 267, 291, 14, 629, 8, 1099, 14, 1301, 2487, 12, 298, 885, 531, 267, 291, 14, 629, 8, 1099, 14, 16835, 12, 13636, 624, 297, 3260, 283, 624, 659, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2882, 199, 199, 504, 512, 25530, 14, 31796, 773, 14, 13209, 14, 9970, 14, 3768, 2487, 10701, 492, 334, 272, 5454, 2487, 10701, 9, 421, 199, 533, 5454, 2487, 10701, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1633, 63, 3615, 867, 425, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 3393, 304, 288, 5454, 2487, 10701, 480, 11720, 401, 298, 1117, 1702, 9289, 401, 19110, 309, 401, 5426, 1288, 430, 398, 543, 291, 14, 1855, 8, 3393, 304, 288, 5454, 2487, 10701, 480, 5408, 3927, 36, 13, 4521, 401, 3044, 298, 15820, 320, 20515, 401, 3044, 19110, 309, 22758, 298, 88, 401, 298, 89, 401, 298, 90, 1288, 430, 398, 543, 291, 14, 1855, 8, 3393, 304, 288, 5454, 2487, 10701, 480, 11720, 401, 3044, 298, 1117, 20515, 401, 3044, 19110, 309, 401, 4873, 5426, 1288, 661, 624, 297, 283, 624, 7058, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 5454, 2487, 10701, 8, 4288, 12, 2097, 1117, 20515, 2255, 13636, 624, 297, 283, 624, 7058, 339, 347, 511, 63, 3282, 8, 277, 304, 267, 399, 337, 275, 5454, 2487, 10701, 480, 35, 401, 298, 1117, 20515, 401, 334, 4769, 538, 401, 8969, 401, 8969, 15, 1288, 430, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 67, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1117, 20515, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 334, 4769, 538, 401, 8969, 401, 8969, 15, 1288, 430, 398, 399, 337, 275, 5454, 2487, 10701, 480, 11720, 401, 298, 1117, 1702, 9289, 401, 10003, 309, 401, 4873, 5426, 13403, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 1548, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1117, 20515, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 19110, 309, 401, 4873, 5426, 1288, 430, 398, 399, 337, 275, 5454, 2487, 10701, 480, 41, 18, 35, 401, 639, 298, 1662, 13, 4229, 13, 3557, 401, 639, 334, 905, 1714, 401, 3286, 94, 401, 3286, 94, 2255, 1689, 30, 17716, 298, 1140, 401, 298, 1140, 13324, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 73, 18, 67, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1662, 13, 4229, 13, 3557, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 19110, 1714, 401, 3286, 94, 401, 3286, 94, 1288, 1689, 30, 17716, 298, 1140, 401, 298, 1140, 13324, 398, 399, 337, 275, 5454, 2487, 10701, 480, 19705, 401, 298, 1117, 20515, 401, 1689, 1714, 401, 3286, 94, 401, 3286, 94, 2237, 398, 291, 14, 629, 8, 85, 337, 14, 3671, 12, 298, 5910, 531, 267, 291, 14, 629, 8, 85, 337, 14, 1301, 2487, 12, 298, 1117, 20515, 531, 267, 291, 14, 629, 8, 85, 337, 14, 16835, 12, 19110, 1714, 401, 3286, 94, 401, 3286, 94, 1288, 430, 339, 347, 511, 63, 912, 8, 277, 304, 267, 327, 1379, 625, 11616, 1382, 2487, 14, 267, 543, 291, 14, 1855, 8, 1173, 10870, 304, 288, 2163, 8, 3768, 2487, 10701, 14, 912, 480, 11720, 401, 298, 9692, 2237, 398, 327, 1379, 625, 11616, 2637, 315, 3411, 1382, 2487, 14, 267, 543, 291, 14, 1855, 8, 10230, 304, 288, 2163, 8, 3768, 2487, 10701, 14, 912, 480, 66, 1728, 13, 65, 13, 696, 415, 401, 298, 885, 2237, 398, 327, 1379, 6835, 1423, 730, 14, 267, 543, 291, 14, 1855, 8, 4333, 304, 288, 2163, 8, 3768, 2487, 10701, 14, 912, 8, 4288, 12, 2097, 513, 13045, 398, 327, 1379, 2366, 650, 849, 2897, 436, 340, 8137, 365, 4565, 267, 327, 2451, 14, 267, 754, 275, 5454, 2487, 10701, 14, 912, 480, 11720, 19, 401, 298, 885, 531, 398, 291, 14, 629, 8, 1099, 14, 3671, 12, 298, 1548, 19, 531, 267, 291, 14, 629, 8, 1099, 14, 1301, 2487, 12, 298, 885, 531, 267, 291, 14, 629, 8, 1099, 14, 16835, 12, 13636, 624, 297, 3260, 283, 624, 659, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0, 0, 0, 0, 0 ]
40223145c2g18/c2g18
w2/static/Brython2.0.0-20140209-164925/Lib/signal.py
743
1646
"""This module provides mechanisms to use signal handlers in Python. Functions: alarm() -- cause SIGALRM after a specified time [Unix only] setitimer() -- cause a signal (described below) after a specified float time and the timer may restart then [Unix only] getitimer() -- get current value of timer [Unix only] signal() -- set the action for a given signal getsignal() -- get the signal action for a given signal pause() -- wait until a signal arrives [Unix only] default_int_handler() -- default SIGINT handler signal constants: SIG_DFL -- used to refer to the system default handler SIG_IGN -- used to ignore the signal NSIG -- number of defined signals SIGINT, SIGTERM, etc. -- signal numbers itimer constants: ITIMER_REAL -- decrements in real time, and delivers SIGALRM upon expiration ITIMER_VIRTUAL -- decrements only when the process is executing, and delivers SIGVTALRM upon expiration ITIMER_PROF -- decrements both when the process is executing and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration. *** IMPORTANT NOTICE *** A signal handler function is called with two arguments: the first is the signal number, the second is the interrupted stack frame.""" CTRL_BREAK_EVENT=1 CTRL_C_EVENT=0 NSIG=23 SIGABRT=22 SIGBREAK=21 SIGFPE=8 SIGILL=4 SIGINT=2 SIGSEGV=11 SIGTERM=15 SIG_DFL=0 SIG_IGN=1 def signal(signalnum, handler) : pass
gpl-2.0
[ 624, 2765, 859, 6571, 562, 10832, 706, 370, 675, 4673, 8297, 315, 2018, 14, 199, 199, 13967, 26, 199, 199, 14160, 342, 1553, 7675, 15522, 748, 11026, 2410, 282, 2013, 900, 359, 21607, 1454, 61, 199, 261, 280, 7414, 342, 1553, 7675, 282, 4673, 334, 271, 14922, 5084, 9, 2410, 282, 2013, 2049, 2069, 900, 436, 314, 9715, 1443, 11004, 2066, 359, 21607, 1454, 61, 199, 303, 280, 7414, 342, 1553, 664, 1453, 574, 402, 9715, 359, 21607, 1454, 61, 199, 4653, 342, 1553, 663, 314, 1595, 367, 282, 1627, 4673, 199, 362, 4653, 342, 1553, 664, 314, 4673, 1595, 367, 282, 1627, 4673, 199, 11241, 342, 1553, 3618, 5133, 282, 4673, 601, 322, 2310, 359, 21607, 1454, 61, 199, 885, 63, 442, 63, 2232, 342, 1553, 849, 15522, 2919, 3016, 199, 199, 4653, 5262, 26, 199, 7864, 63, 36, 3143, 1553, 1202, 370, 10618, 370, 314, 2656, 849, 3016, 199, 7864, 63, 3203, 1553, 1202, 370, 3686, 314, 4673, 199, 2709, 1277, 1553, 1329, 402, 3247, 10166, 199, 21223, 12, 15522, 16718, 12, 5423, 14, 1553, 4673, 5579, 199, 199, 73, 7414, 5262, 26, 199, 649, 1469, 540, 63, 15508, 1553, 477, 1353, 1470, 315, 3363, 900, 12, 436, 9122, 14895, 15522, 748, 11026, 12188, 2049, 15399, 199, 649, 1469, 540, 63, 25618, 1553, 477, 1353, 1470, 1454, 1380, 314, 2112, 365, 14043, 12, 2049, 436, 9122, 14895, 15522, 8156, 748, 11026, 12188, 15399, 199, 649, 1469, 540, 63, 2514, 38, 1553, 477, 1353, 1470, 3865, 1380, 314, 2112, 365, 14043, 436, 2049, 1380, 314, 2656, 365, 14043, 641, 506, 10220, 402, 314, 2112, 14, 2049, 1849, 10769, 543, 473, 29108, 63, 25618, 12, 642, 9715, 365, 9987, 2049, 1202, 370, 4690, 314, 900, 2249, 484, 701, 314, 4223, 2049, 315, 922, 436, 5114, 4601, 14, 15522, 2514, 38, 365, 28218, 12188, 2049, 15399, 14, 421, 199, 9153, 5025, 2596, 1441, 12840, 19688, 199, 33, 4673, 3016, 805, 365, 2797, 543, 2877, 2368, 26, 199, 1589, 1642, 365, 314, 4673, 1329, 12, 314, 3499, 365, 314, 31366, 3464, 2787, 1041, 199, 199, 22584, 63, 14731, 63, 8193, 29, 17, 199, 22584, 63, 35, 63, 8193, 29, 16, 199, 2709, 1277, 29, 1789, 199, 7864, 1217, 11876, 29, 1081, 199, 7864, 14731, 29, 2025, 199, 7864, 38, 1510, 29, 24, 199, 7864, 14961, 29, 20, 199, 21223, 29, 18, 199, 7864, 899, 14876, 29, 845, 199, 29190, 29, 1046, 199, 7864, 63, 36, 3143, 29, 16, 199, 7864, 63, 3203, 29, 17, 199, 199, 318, 4673, 8, 4653, 1507, 12, 3016, 9, 520, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2765, 859, 6571, 562, 10832, 706, 370, 675, 4673, 8297, 315, 2018, 14, 199, 199, 13967, 26, 199, 199, 14160, 342, 1553, 7675, 15522, 748, 11026, 2410, 282, 2013, 900, 359, 21607, 1454, 61, 199, 261, 280, 7414, 342, 1553, 7675, 282, 4673, 334, 271, 14922, 5084, 9, 2410, 282, 2013, 2049, 2069, 900, 436, 314, 9715, 1443, 11004, 2066, 359, 21607, 1454, 61, 199, 303, 280, 7414, 342, 1553, 664, 1453, 574, 402, 9715, 359, 21607, 1454, 61, 199, 4653, 342, 1553, 663, 314, 1595, 367, 282, 1627, 4673, 199, 362, 4653, 342, 1553, 664, 314, 4673, 1595, 367, 282, 1627, 4673, 199, 11241, 342, 1553, 3618, 5133, 282, 4673, 601, 322, 2310, 359, 21607, 1454, 61, 199, 885, 63, 442, 63, 2232, 342, 1553, 849, 15522, 2919, 3016, 199, 199, 4653, 5262, 26, 199, 7864, 63, 36, 3143, 1553, 1202, 370, 10618, 370, 314, 2656, 849, 3016, 199, 7864, 63, 3203, 1553, 1202, 370, 3686, 314, 4673, 199, 2709, 1277, 1553, 1329, 402, 3247, 10166, 199, 21223, 12, 15522, 16718, 12, 5423, 14, 1553, 4673, 5579, 199, 199, 73, 7414, 5262, 26, 199, 649, 1469, 540, 63, 15508, 1553, 477, 1353, 1470, 315, 3363, 900, 12, 436, 9122, 14895, 15522, 748, 11026, 12188, 2049, 15399, 199, 649, 1469, 540, 63, 25618, 1553, 477, 1353, 1470, 1454, 1380, 314, 2112, 365, 14043, 12, 2049, 436, 9122, 14895, 15522, 8156, 748, 11026, 12188, 15399, 199, 649, 1469, 540, 63, 2514, 38, 1553, 477, 1353, 1470, 3865, 1380, 314, 2112, 365, 14043, 436, 2049, 1380, 314, 2656, 365, 14043, 641, 506, 10220, 402, 314, 2112, 14, 2049, 1849, 10769, 543, 473, 29108, 63, 25618, 12, 642, 9715, 365, 9987, 2049, 1202, 370, 4690, 314, 900, 2249, 484, 701, 314, 4223, 2049, 315, 922, 436, 5114, 4601, 14, 15522, 2514, 38, 365, 28218, 12188, 2049, 15399, 14, 421, 199, 9153, 5025, 2596, 1441, 12840, 19688, 199, 33, 4673, 3016, 805, 365, 2797, 543, 2877, 2368, 26, 199, 1589, 1642, 365, 314, 4673, 1329, 12, 314, 3499, 365, 314, 31366, 3464, 2787, 1041, 199, 199, 22584, 63, 14731, 63, 8193, 29, 17, 199, 22584, 63, 35, 63, 8193, 29, 16, 199, 2709, 1277, 29, 1789, 199, 7864, 1217, 11876, 29, 1081, 199, 7864, 14731, 29, 2025, 199, 7864, 38, 1510, 29, 24, 199, 7864, 14961, 29, 20, 199, 21223, 29, 18, 199, 7864, 899, 14876, 29, 845, 199, 29190, 29, 1046, 199, 7864, 63, 36, 3143, 29, 16, 199, 7864, 63, 3203, 29, 17, 199, 199, 318, 4673, 8, 4653, 1507, 12, 3016, 9, 520, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ioggstream/python-course
ansible-101/notebooks/exercise-05/inventory-docker-solution.py
1
1376
#!/usr/bin/env python # List our containers. Note: this only works with docker-compose containers. from __future__ import print_function from collections import defaultdict import json # # Manage different docker libraries # try: from docker import Client except ImportError: from docker import APIClient as Client import logging log = logging.getLogger() logging.basicConfig(level=logging.DEBUG) def print_hosts(): c=Client(base_url="http://172.17.0.1:2375") container_fmt = lambda x: ( x['Names'][0][1:], x['NetworkSettings']['Networks']['bridge']['IPAddress'], ) inventory = dict() for x in c.containers(): log.debug("Processing entry %r", '\t\t'.join(container_fmt(x))) try: group_name = x['Labels']['com.docker.compose.service'] ip_address = x['NetworkSettings']['Networks']['bridge']['IPAddress'] if group_name not in inventory: inventory[group_name] = defaultdict(list) inventory[group_name]['hosts'].append(ip_address) except KeyError: log.warning("Host not run via docker-compose: skipping") inventory['web']['host_vars'] = {'ansible_ssh_common_args': ' -o StrictHostKeyChecking=no '} ret = json.dumps(inventory, indent=True) return ret if __name__ == '__main__': print(print_hosts())
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3820, 4154, 15333, 14, 3390, 26, 642, 1454, 5419, 543, 12424, 13, 12607, 15333, 14, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 5055, 492, 10018, 199, 646, 2022, 421, 199, 3, 221, 199, 3, 14944, 3365, 12424, 8363, 199, 3, 199, 893, 26, 272, 687, 12424, 492, 6810, 199, 2590, 3545, 26, 272, 687, 12424, 492, 25418, 864, 465, 6810, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 342, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 199, 199, 318, 870, 63, 5146, 837, 272, 286, 29, 3041, 8, 1095, 63, 633, 628, 1014, 921, 10419, 14, 1196, 14, 16, 14, 17, 26, 18, 9946, 531, 272, 3970, 63, 5045, 275, 2400, 671, 26, 334, 267, 671, 459, 5866, 3488, 16, 1527, 17, 8429, 267, 671, 459, 4491, 5268, 2545, 30551, 2545, 9528, 2545, 14955, 995, 272, 776, 2286, 8200, 275, 1211, 342, 221, 2286, 367, 671, 315, 286, 14, 13577, 837, 267, 943, 14, 1757, 480, 9589, 2397, 450, 82, 401, 1557, 84, 60, 84, 1370, 904, 8, 3600, 63, 5045, 8, 88, 1724, 267, 862, 26, 288, 1572, 63, 354, 275, 671, 459, 14016, 2545, 957, 14, 9991, 14, 12607, 14, 1364, 418, 288, 3384, 63, 1562, 275, 671, 459, 4491, 5268, 2545, 30551, 2545, 9528, 2545, 14955, 418, 288, 340, 1572, 63, 354, 440, 315, 8200, 26, 355, 8200, 59, 923, 63, 354, 61, 275, 10018, 8, 513, 9, 288, 8200, 59, 923, 63, 354, 2733, 5146, 2278, 740, 8, 711, 63, 1562, 9, 267, 871, 4067, 26, 1779, 943, 14, 3764, 480, 4965, 440, 1255, 4799, 12424, 13, 12607, 26, 16068, 531, 2286, 8200, 459, 2520, 2545, 1102, 63, 2936, 418, 275, 791, 4853, 63, 5510, 63, 2330, 63, 589, 356, 283, 446, 79, 23052, 4965, 1197, 14740, 29, 889, 28544, 272, 2203, 275, 2022, 14, 4180, 8, 7212, 12, 4363, 29, 549, 9, 272, 372, 2203, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 870, 8, 1361, 63, 5146, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3820, 4154, 15333, 14, 3390, 26, 642, 1454, 5419, 543, 12424, 13, 12607, 15333, 14, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 5055, 492, 10018, 199, 646, 2022, 421, 199, 3, 221, 199, 3, 14944, 3365, 12424, 8363, 199, 3, 199, 893, 26, 272, 687, 12424, 492, 6810, 199, 2590, 3545, 26, 272, 687, 12424, 492, 25418, 864, 465, 6810, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 342, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 199, 199, 318, 870, 63, 5146, 837, 272, 286, 29, 3041, 8, 1095, 63, 633, 628, 1014, 921, 10419, 14, 1196, 14, 16, 14, 17, 26, 18, 9946, 531, 272, 3970, 63, 5045, 275, 2400, 671, 26, 334, 267, 671, 459, 5866, 3488, 16, 1527, 17, 8429, 267, 671, 459, 4491, 5268, 2545, 30551, 2545, 9528, 2545, 14955, 995, 272, 776, 2286, 8200, 275, 1211, 342, 221, 2286, 367, 671, 315, 286, 14, 13577, 837, 267, 943, 14, 1757, 480, 9589, 2397, 450, 82, 401, 1557, 84, 60, 84, 1370, 904, 8, 3600, 63, 5045, 8, 88, 1724, 267, 862, 26, 288, 1572, 63, 354, 275, 671, 459, 14016, 2545, 957, 14, 9991, 14, 12607, 14, 1364, 418, 288, 3384, 63, 1562, 275, 671, 459, 4491, 5268, 2545, 30551, 2545, 9528, 2545, 14955, 418, 288, 340, 1572, 63, 354, 440, 315, 8200, 26, 355, 8200, 59, 923, 63, 354, 61, 275, 10018, 8, 513, 9, 288, 8200, 59, 923, 63, 354, 2733, 5146, 2278, 740, 8, 711, 63, 1562, 9, 267, 871, 4067, 26, 1779, 943, 14, 3764, 480, 4965, 440, 1255, 4799, 12424, 13, 12607, 26, 16068, 531, 2286, 8200, 459, 2520, 2545, 1102, 63, 2936, 418, 275, 791, 4853, 63, 5510, 63, 2330, 63, 589, 356, 283, 446, 79, 23052, 4965, 1197, 14740, 29, 889, 28544, 272, 2203, 275, 2022, 14, 4180, 8, 7212, 12, 4363, 29, 549, 9, 272, 372, 2203, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 870, 8, 1361, 63, 5146, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
AlexOugh/horizon
horizon/base.py
3
37049
# Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Contains the core classes and functionality that makes Horizon what it is. This module is considered internal, and should not be relied on directly. Public APIs are made available through the :mod:`horizon` module and the classes contained therein. """ import collections import copy import inspect import logging import os from django.conf import settings from django.conf.urls import include from django.conf.urls import patterns from django.conf.urls import url from django.core.exceptions import ImproperlyConfigured # noqa from django.core.urlresolvers import reverse from django.utils.datastructures import SortedDict from django.utils.functional import SimpleLazyObject # noqa from django.utils.importlib import import_module # noqa from django.utils.module_loading import module_has_submodule # noqa from django.utils.translation import ugettext_lazy as _ from horizon import conf from horizon.decorators import _current_component # noqa from horizon.decorators import require_auth # noqa from horizon.decorators import require_perms # noqa from horizon import loaders LOG = logging.getLogger(__name__) def _decorate_urlconf(urlpatterns, decorator, *args, **kwargs): for pattern in urlpatterns: if getattr(pattern, 'callback', None): pattern._callback = decorator(pattern.callback, *args, **kwargs) if getattr(pattern, 'url_patterns', []): _decorate_urlconf(pattern.url_patterns, decorator, *args, **kwargs) def access_cached(func): def inner(self, context): session = context['request'].session try: if session['allowed']['valid_for'] != session.get('token'): raise KeyError() except KeyError: session['allowed'] = {"valid_for": session.get('token')} key = "%s.%s" % (self.__class__.__module__, self.__class__.__name__) if key not in session['allowed']: session['allowed'][key] = func(self, context) session.modified = True return session['allowed'][key] return inner class NotRegistered(Exception): pass class HorizonComponent(object): policy_rules = None def __init__(self): super(HorizonComponent, self).__init__() if not self.slug: raise ImproperlyConfigured('Every %s must have a slug.' % self.__class__) def __unicode__(self): name = getattr(self, 'name', u"Unnamed %s" % self.__class__.__name__) return unicode(name) def _get_default_urlpatterns(self): package_string = '.'.join(self.__module__.split('.')[:-1]) if getattr(self, 'urls', None): try: mod = import_module('.%s' % self.urls, package_string) except ImportError: mod = import_module(self.urls) urlpatterns = mod.urlpatterns else: # Try importing a urls.py from the dashboard package if module_has_submodule(import_module(package_string), 'urls'): urls_mod = import_module('.urls', package_string) urlpatterns = urls_mod.urlpatterns else: urlpatterns = patterns('') return urlpatterns @access_cached def can_access(self, context): """Return whether the user has role based access to this component. This method is not intended to be overridden. The result of the method is stored in per-session cache. """ return self.allowed(context) def allowed(self, context): """Checks if the user is allowed to access this component. This method should be overridden to return the result of any policy checks required for the user to access this component when more complex checks are required. """ return self._can_access(context['request']) def _can_access(self, request): policy_check = getattr(settings, "POLICY_CHECK_FUNCTION", None) # this check is an OR check rather than an AND check that is the # default in the policy engine, so calling each rule individually if policy_check and self.policy_rules: for rule in self.policy_rules: if policy_check((rule,), request): return True return False # default to allowed return True class Registry(object): def __init__(self): self._registry = {} if not getattr(self, '_registerable_class', None): raise ImproperlyConfigured('Subclasses of Registry must set a ' '"_registerable_class" property.') def _register(self, cls): """Registers the given class. If the specified class is already registered then it is ignored. """ if not inspect.isclass(cls): raise ValueError('Only classes may be registered.') elif not issubclass(cls, self._registerable_class): raise ValueError('Only %s classes or subclasses may be registered.' % self._registerable_class.__name__) if cls not in self._registry: cls._registered_with = self self._registry[cls] = cls() return self._registry[cls] def _unregister(self, cls): """Unregisters the given class. If the specified class isn't registered, ``NotRegistered`` will be raised. """ if not issubclass(cls, self._registerable_class): raise ValueError('Only %s classes or subclasses may be ' 'unregistered.' % self._registerable_class) if cls not in self._registry.keys(): raise NotRegistered('%s is not registered' % cls) del self._registry[cls] return True def _registered(self, cls): if inspect.isclass(cls) and issubclass(cls, self._registerable_class): found = self._registry.get(cls, None) if found: return found else: # Allow for fetching by slugs as well. for registered in self._registry.values(): if registered.slug == cls: return registered class_name = self._registerable_class.__name__ if hasattr(self, "_registered_with"): parent = self._registered_with._registerable_class.__name__ raise NotRegistered('%(type)s with slug "%(slug)s" is not ' 'registered with %(parent)s "%(name)s".' % {"type": class_name, "slug": cls, "parent": parent, "name": self.slug}) else: slug = getattr(cls, "slug", cls) raise NotRegistered('%(type)s with slug "%(slug)s" is not ' 'registered.' % {"type": class_name, "slug": slug}) class Panel(HorizonComponent): """A base class for defining Horizon dashboard panels. All Horizon dashboard panels should extend from this class. It provides the appropriate hooks for automatically constructing URLconfs, and providing permission-based access control. .. attribute:: name The name of the panel. This will be displayed in the auto-generated navigation and various other places. Default: ``''``. .. attribute:: slug A unique "short name" for the panel. The slug is used as a component of the URL path for the panel. Default: ``''``. .. attribute:: permissions A list of permission names, all of which a user must possess in order to access any view associated with this panel. This attribute is combined cumulatively with any permissions required on the ``Dashboard`` class with which it is registered. .. attribute:: urls Path to a URLconf of views for this panel using dotted Python notation. If no value is specified, a file called ``urls.py`` living in the same package as the ``panel.py`` file is used. Default: ``None``. .. attribute:: nav .. method:: nav(context) The ``nav`` attribute can be either boolean value or a callable which accepts a ``RequestContext`` object as a single argument to control whether or not this panel should appear in automatically-generated navigation. Default: ``True``. .. attribute:: index_url_name The ``name`` argument for the URL pattern which corresponds to the index view for this ``Panel``. This is the view that :meth:`.Panel.get_absolute_url` will attempt to reverse. """ name = '' slug = '' urls = None nav = True index_url_name = "index" def __repr__(self): return "<Panel: %s>" % self.slug def get_absolute_url(self): """Returns the default URL for this panel. The default URL is defined as the URL pattern with ``name="index"`` in the URLconf for this panel. """ try: return reverse('horizon:%s:%s:%s' % (self._registered_with.slug, self.slug, self.index_url_name)) except Exception as exc: # Logging here since this will often be called in a template # where the exception would be hidden. LOG.info("Error reversing absolute URL for %s: %s" % (self, exc)) raise @property def _decorated_urls(self): urlpatterns = self._get_default_urlpatterns() # Apply access controls to all views in the patterns permissions = getattr(self, 'permissions', []) _decorate_urlconf(urlpatterns, require_perms, permissions) _decorate_urlconf(urlpatterns, _current_component, panel=self) # Return the three arguments to django.conf.urls.include return urlpatterns, self.slug, self.slug class PanelGroup(object): """A container for a set of :class:`~horizon.Panel` classes. When iterated, it will yield each of the ``Panel`` instances it contains. .. attribute:: slug A unique string to identify this panel group. Required. .. attribute:: name A user-friendly name which will be used as the group heading in places such as the navigation. Default: ``None``. .. attribute:: panels A list of panel module names which should be contained within this grouping. """ def __init__(self, dashboard, slug=None, name=None, panels=None): self.dashboard = dashboard self.slug = slug or getattr(self, "slug", "default") self.name = name or getattr(self, "name", None) # Our panels must be mutable so it can be extended by others. self.panels = list(panels or getattr(self, "panels", [])) def __repr__(self): return "<%s: %s>" % (self.__class__.__name__, self.slug) def __unicode__(self): return self.name def __iter__(self): panel_instances = [] for name in self.panels: try: panel_instances.append(self.dashboard.get_panel(name)) except NotRegistered as e: LOG.debug(e) return iter(panel_instances) class Dashboard(Registry, HorizonComponent): """A base class for defining Horizon dashboards. All Horizon dashboards should extend from this base class. It provides the appropriate hooks for automatic discovery of :class:`~horizon.Panel` modules, automatically constructing URLconfs, and providing permission-based access control. .. attribute:: name The name of the dashboard. This will be displayed in the auto-generated navigation and various other places. Default: ``''``. .. attribute:: slug A unique "short name" for the dashboard. The slug is used as a component of the URL path for the dashboard. Default: ``''``. .. attribute:: panels The ``panels`` attribute can be either a flat list containing the name of each panel **module** which should be loaded as part of this dashboard, or a list of :class:`~horizon.PanelGroup` classes which define groups of panels as in the following example:: class SystemPanels(horizon.PanelGroup): slug = "syspanel" name = _("System") panels = ('overview', 'instances', ...) class Syspanel(horizon.Dashboard): panels = (SystemPanels,) Automatically generated navigation will use the order of the modules in this attribute. Default: ``[]``. .. warning:: The values for this attribute should not correspond to the :attr:`~.Panel.name` attributes of the ``Panel`` classes. They should be the names of the Python modules in which the ``panel.py`` files live. This is used for the automatic loading and registration of ``Panel`` classes much like Django's ``ModelAdmin`` machinery. Panel modules must be listed in ``panels`` in order to be discovered by the automatic registration mechanism. .. attribute:: default_panel The name of the panel which should be treated as the default panel for the dashboard, i.e. when you visit the root URL for this dashboard, that's the panel that is displayed. Default: ``None``. .. attribute:: permissions A list of permission names, all of which a user must possess in order to access any panel registered with this dashboard. This attribute is combined cumulatively with any permissions required on individual :class:`~horizon.Panel` classes. .. attribute:: urls Optional path to a URLconf of additional views for this dashboard which are not connected to specific panels. Default: ``None``. .. attribute:: nav .. method:: nav(context) The ``nav`` attribute can be either boolean value or a callable which accepts a ``RequestContext`` object as a single argument to control whether or not this dashboard should appear in automatically-generated navigation. Default: ``True``. .. attribute:: supports_tenants Optional boolean that indicates whether or not this dashboard includes support for projects/tenants. If set to ``True`` this dashboard's navigation will include a UI element that allows the user to select project/tenant. Default: ``False``. .. attribute:: public Boolean value to determine whether this dashboard can be viewed without being logged in. Defaults to ``False``. """ _registerable_class = Panel name = '' slug = '' urls = None panels = [] default_panel = None nav = True supports_tenants = False public = False def __repr__(self): return "<Dashboard: %s>" % self.slug def __init__(self, *args, **kwargs): super(Dashboard, self).__init__(*args, **kwargs) self._panel_groups = None def get_panel(self, panel): """Returns the specified :class:`~horizon.Panel` instance registered with this dashboard. """ return self._registered(panel) def get_panels(self): """Returns the :class:`~horizon.Panel` instances registered with this dashboard in order, without any panel groupings. """ all_panels = [] panel_groups = self.get_panel_groups() for panel_group in panel_groups.values(): all_panels.extend(panel_group) return all_panels def get_panel_group(self, slug): """Returns the specified :class:~horizon.PanelGroup or None if not registered """ return self._panel_groups.get(slug) def get_panel_groups(self): registered = copy.copy(self._registry) panel_groups = [] # Gather our known panels if self._panel_groups is not None: for panel_group in self._panel_groups.values(): for panel in panel_group: registered.pop(panel.__class__) panel_groups.append((panel_group.slug, panel_group)) # Deal with leftovers (such as add-on registrations) if len(registered): slugs = [panel.slug for panel in registered.values()] new_group = PanelGroup(self, slug="other", name=_("Other"), panels=slugs) panel_groups.append((new_group.slug, new_group)) return SortedDict(panel_groups) def get_absolute_url(self): """Returns the default URL for this dashboard. The default URL is defined as the URL pattern with ``name="index"`` in the URLconf for the :class:`~horizon.Panel` specified by :attr:`~horizon.Dashboard.default_panel`. """ try: return self._registered(self.default_panel).get_absolute_url() except Exception: # Logging here since this will often be called in a template # where the exception would be hidden. LOG.exception("Error reversing absolute URL for %s." % self) raise @property def _decorated_urls(self): urlpatterns = self._get_default_urlpatterns() default_panel = None # Add in each panel's views except for the default view. for panel in self._registry.values(): if panel.slug == self.default_panel: default_panel = panel continue url_slug = panel.slug.replace('.', '/') urlpatterns += patterns('', url(r'^%s/' % url_slug, include(panel._decorated_urls))) # Now the default view, which should come last if not default_panel: raise NotRegistered('The default panel "%s" is not registered.' % self.default_panel) urlpatterns += patterns('', url(r'', include(default_panel._decorated_urls))) # Require login if not public. if not self.public: _decorate_urlconf(urlpatterns, require_auth) # Apply access controls to all views in the patterns permissions = getattr(self, 'permissions', []) _decorate_urlconf(urlpatterns, require_perms, permissions) _decorate_urlconf(urlpatterns, _current_component, dashboard=self) # Return the three arguments to django.conf.urls.include return urlpatterns, self.slug, self.slug def _autodiscover(self): """Discovers panels to register from the current dashboard module.""" if getattr(self, "_autodiscover_complete", False): return panels_to_discover = [] panel_groups = [] # If we have a flat iterable of panel names, wrap it again so # we have a consistent structure for the next step. if all([isinstance(i, basestring) for i in self.panels]): self.panels = [self.panels] # Now iterate our panel sets. for panel_set in self.panels: # Instantiate PanelGroup classes. if not isinstance(panel_set, collections.Iterable) and \ issubclass(panel_set, PanelGroup): panel_group = panel_set(self) # Check for nested tuples, and convert them to PanelGroups elif not isinstance(panel_set, PanelGroup): panel_group = PanelGroup(self, panels=panel_set) # Put our results into their appropriate places panels_to_discover.extend(panel_group.panels) panel_groups.append((panel_group.slug, panel_group)) self._panel_groups = SortedDict(panel_groups) # Do the actual discovery package = '.'.join(self.__module__.split('.')[:-1]) mod = import_module(package) for panel in panels_to_discover: try: before_import_registry = copy.copy(self._registry) import_module('.%s.panel' % panel, package) except Exception: self._registry = before_import_registry if module_has_submodule(mod, panel): raise self._autodiscover_complete = True @classmethod def register(cls, panel): """Registers a :class:`~horizon.Panel` with this dashboard.""" panel_class = Horizon.register_panel(cls, panel) # Support template loading from panel template directories. panel_mod = import_module(panel.__module__) panel_dir = os.path.dirname(panel_mod.__file__) template_dir = os.path.join(panel_dir, "templates") if os.path.exists(template_dir): key = os.path.join(cls.slug, panel.slug) loaders.panel_template_dirs[key] = template_dir return panel_class @classmethod def unregister(cls, panel): """Unregisters a :class:`~horizon.Panel` from this dashboard.""" success = Horizon.unregister_panel(cls, panel) if success: # Remove the panel's template directory. key = os.path.join(cls.slug, panel.slug) if key in loaders.panel_template_dirs: del loaders.panel_template_dirs[key] return success def allowed(self, context): """Checks for role based access for this dashboard. Checks for access to any panels in the dashboard and of the the dashboard itself. This method should be overridden to return the result of any policy checks required for the user to access this dashboard when more complex checks are required. """ # if the dashboard has policy rules, honor those above individual # panels if not self._can_access(context['request']): return False # check if access is allowed to a single panel, # the default for each panel is True for panel in self.get_panels(): if panel.can_access(context): return True return False class Workflow(object): pass try: from django.utils.functional import empty # noqa except ImportError: # Django 1.3 fallback empty = None class LazyURLPattern(SimpleLazyObject): def __iter__(self): if self._wrapped is empty: self._setup() return iter(self._wrapped) def __reversed__(self): if self._wrapped is empty: self._setup() return reversed(self._wrapped) def __len__(self): if self._wrapped is empty: self._setup() return len(self._wrapped) def __getitem__(self, idx): if self._wrapped is empty: self._setup() return self._wrapped[idx] class Site(Registry, HorizonComponent): """The overarching class which encompasses all dashboards and panels.""" # Required for registry _registerable_class = Dashboard name = "Horizon" namespace = 'horizon' slug = 'horizon' urls = 'horizon.site_urls' def __repr__(self): return u"<Site: %s>" % self.slug @property def _conf(self): return conf.HORIZON_CONFIG @property def dashboards(self): return self._conf['dashboards'] @property def default_dashboard(self): return self._conf['default_dashboard'] def register(self, dashboard): """Registers a :class:`~horizon.Dashboard` with Horizon.""" return self._register(dashboard) def unregister(self, dashboard): """Unregisters a :class:`~horizon.Dashboard` from Horizon.""" return self._unregister(dashboard) def registered(self, dashboard): return self._registered(dashboard) def register_panel(self, dashboard, panel): dash_instance = self.registered(dashboard) return dash_instance._register(panel) def unregister_panel(self, dashboard, panel): dash_instance = self.registered(dashboard) if not dash_instance: raise NotRegistered("The dashboard %s is not registered." % dashboard) return dash_instance._unregister(panel) def get_dashboard(self, dashboard): """Returns the specified :class:`~horizon.Dashboard` instance.""" return self._registered(dashboard) def get_dashboards(self): """Returns an ordered tuple of :class:`~horizon.Dashboard` modules. Orders dashboards according to the ``"dashboards"`` key in ``HORIZON_CONFIG`` or else returns all registered dashboards in alphabetical order. Any remaining :class:`~horizon.Dashboard` classes registered with Horizon but not listed in ``HORIZON_CONFIG['dashboards']`` will be appended to the end of the list alphabetically. """ if self.dashboards: registered = copy.copy(self._registry) dashboards = [] for item in self.dashboards: dashboard = self._registered(item) dashboards.append(dashboard) registered.pop(dashboard.__class__) if len(registered): extra = registered.values() extra.sort() dashboards.extend(extra) return dashboards else: dashboards = self._registry.values() dashboards.sort() return dashboards def get_default_dashboard(self): """Returns the default :class:`~horizon.Dashboard` instance. If ``"default_dashboard"`` is specified in ``HORIZON_CONFIG`` then that dashboard will be returned. If not, the first dashboard returned by :func:`~horizon.get_dashboards` will be returned. """ if self.default_dashboard: return self._registered(self.default_dashboard) elif len(self._registry): return self.get_dashboards()[0] else: raise NotRegistered("No dashboard modules have been registered.") def get_user_home(self, user): """Returns the default URL for a particular user. This method can be used to customize where a user is sent when they log in, etc. By default it returns the value of :meth:`get_absolute_url`. An alternative function can be supplied to customize this behavior by specifying a either a URL or a function which returns a URL via the ``"user_home"`` key in ``HORIZON_CONFIG``. Each of these would be valid:: {"user_home": "/home",} # A URL {"user_home": "my_module.get_user_home",} # Path to a function {"user_home": lambda user: "/" + user.name,} # A function {"user_home": None,} # Will always return the default dashboard This can be useful if the default dashboard may not be accessible to all users. When user_home is missing from HORIZON_CONFIG, it will default to the settings.LOGIN_REDIRECT_URL value. """ user_home = self._conf['user_home'] if user_home: if callable(user_home): return user_home(user) elif isinstance(user_home, basestring): # Assume we've got a URL if there's a slash in it if '/' in user_home: return user_home else: mod, func = user_home.rsplit(".", 1) return getattr(import_module(mod), func)(user) # If it's not callable and not a string, it's wrong. raise ValueError('The user_home setting must be either a string ' 'or a callable object (e.g. a function).') else: return self.get_absolute_url() def get_absolute_url(self): """Returns the default URL for Horizon's URLconf. The default URL is determined by calling :meth:`~horizon.Dashboard.get_absolute_url` on the :class:`~horizon.Dashboard` instance returned by :meth:`~horizon.get_default_dashboard`. """ return self.get_default_dashboard().get_absolute_url() @property def _lazy_urls(self): """Lazy loading for URL patterns. This method avoids problems associated with attempting to evaluate the URLconf before the settings module has been loaded. """ def url_patterns(): return self._urls()[0] return LazyURLPattern(url_patterns), self.namespace, self.slug def _urls(self): """Constructs the URLconf for Horizon from registered Dashboards.""" urlpatterns = self._get_default_urlpatterns() self._autodiscover() # Discover each dashboard's panels. for dash in self._registry.values(): dash._autodiscover() # Load the plugin-based panel configuration self._load_panel_customization() # Allow for override modules if self._conf.get("customization_module", None): customization_module = self._conf["customization_module"] bits = customization_module.split('.') mod_name = bits.pop() package = '.'.join(bits) mod = import_module(package) try: before_import_registry = copy.copy(self._registry) import_module('%s.%s' % (package, mod_name)) except Exception: self._registry = before_import_registry if module_has_submodule(mod, mod_name): raise # Compile the dynamic urlconf. for dash in self._registry.values(): urlpatterns += patterns('', url(r'^%s/' % dash.slug, include(dash._decorated_urls))) # Return the three arguments to django.conf.urls.include return urlpatterns, self.namespace, self.slug def _autodiscover(self): """Discovers modules to register from ``settings.INSTALLED_APPS``. This makes sure that the appropriate modules get imported to register themselves with Horizon. """ if not getattr(self, '_registerable_class', None): raise ImproperlyConfigured('You must set a ' '"_registerable_class" property ' 'in order to use autodiscovery.') # Discover both dashboards and panels, in that order for mod_name in ('dashboard', 'panel'): for app in settings.INSTALLED_APPS: mod = import_module(app) try: before_import_registry = copy.copy(self._registry) import_module('%s.%s' % (app, mod_name)) except Exception: self._registry = before_import_registry if module_has_submodule(mod, mod_name): raise def _load_panel_customization(self): """Applies the plugin-based panel configurations. This method parses the panel customization from the ``HORIZON_CONFIG`` and make changes to the dashboard accordingly. It supports adding, removing and setting default panels on the dashboard. It also support registering a panel group. """ panel_customization = self._conf.get("panel_customization", []) for config in panel_customization: if config.get('PANEL'): self._process_panel_configuration(config) elif config.get('PANEL_GROUP'): self._process_panel_group_configuration(config) else: LOG.warning("Skipping %s because it doesn't have PANEL or " "PANEL_GROUP defined.", config.__name__) def _process_panel_configuration(self, config): """Add, remove and set default panels on the dashboard.""" try: dashboard = config.get('PANEL_DASHBOARD') if not dashboard: LOG.warning("Skipping %s because it doesn't have " "PANEL_DASHBOARD defined.", config.__name__) return panel_slug = config.get('PANEL') dashboard_cls = self.get_dashboard(dashboard) panel_group = config.get('PANEL_GROUP') default_panel = config.get('DEFAULT_PANEL') # Set the default panel if default_panel: dashboard_cls.default_panel = default_panel # Remove the panel if config.get('REMOVE_PANEL', False): for panel in dashboard_cls.get_panels(): if panel_slug == panel.slug: dashboard_cls.unregister(panel.__class__) elif config.get('ADD_PANEL', None): # Add the panel to the dashboard panel_path = config['ADD_PANEL'] mod_path, panel_cls = panel_path.rsplit(".", 1) try: mod = import_module(mod_path) except ImportError: LOG.warning("Could not load panel: %s", mod_path) return panel = getattr(mod, panel_cls) dashboard_cls.register(panel) if panel_group: dashboard_cls.get_panel_group(panel_group).__class__.\ panels.append(panel.slug) dashboard_cls.get_panel_group(panel_group).\ panels.append(panel.slug) else: panels = list(dashboard_cls.panels) panels.append(panel) dashboard_cls.panels = tuple(panels) except Exception as e: LOG.warning('Could not process panel %(panel)s: %(exc)s', {'panel': panel_slug, 'exc': e}) def _process_panel_group_configuration(self, config): """Adds a panel group to the dashboard.""" panel_group_slug = config.get('PANEL_GROUP') try: dashboard = config.get('PANEL_GROUP_DASHBOARD') if not dashboard: LOG.warning("Skipping %s because it doesn't have " "PANEL_GROUP_DASHBOARD defined.", config.__name__) return dashboard_cls = self.get_dashboard(dashboard) panel_group_name = config.get('PANEL_GROUP_NAME') if not panel_group_name: LOG.warning("Skipping %s because it doesn't have " "PANEL_GROUP_NAME defined.", config.__name__) return # Create the panel group class panel_group = type(panel_group_slug, (PanelGroup, ), {'slug': panel_group_slug, 'name': panel_group_name, 'panels': []},) # Add the panel group to dashboard panels = list(dashboard_cls.panels) panels.append(panel_group) dashboard_cls.panels = tuple(panels) # Trigger the autodiscovery to completely load the new panel group dashboard_cls._autodiscover_complete = False dashboard_cls._autodiscover() except Exception as e: LOG.warning('Could not process panel group %(panel_group)s: ' '%(exc)s', {'panel_group': panel_group_slug, 'exc': e}) class HorizonSite(Site): """A singleton implementation of Site such that all dealings with horizon get the same instance no matter what. There can be only one. """ _instance = None def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = super(Site, cls).__new__(cls, *args, **kwargs) return cls._instance # The one true Horizon Horizon = HorizonSite()
apache-2.0
[ 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 6906, 314, 6170, 3992, 436, 9330, 626, 7704, 869, 11925, 4052, 652, 365, 14, 199, 2765, 859, 365, 8652, 5007, 12, 436, 1077, 440, 506, 295, 1857, 641, 5370, 14, 199, 199, 9885, 15913, 787, 6326, 2808, 4012, 314, 520, 1494, 1705, 16561, 64, 859, 436, 199, 1589, 3992, 10470, 2337, 262, 14, 199, 624, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 6485, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2190, 14, 3603, 492, 2387, 199, 504, 1639, 14, 2190, 14, 3603, 492, 7970, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 221, 327, 8151, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 504, 1639, 14, 1208, 14, 15481, 492, 5870, 14269, 1692, 221, 327, 8151, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 221, 327, 8151, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 859, 63, 1989, 63, 16229, 221, 327, 8151, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 3743, 199, 504, 21726, 14, 11582, 492, 485, 1818, 63, 3173, 221, 327, 8151, 199, 504, 21726, 14, 11582, 492, 4409, 63, 1178, 221, 327, 8151, 199, 504, 21726, 14, 11582, 492, 4409, 63, 12068, 221, 327, 8151, 199, 504, 21726, 492, 25520, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 485, 6518, 323, 63, 21801, 8, 20050, 12, 7531, 12, 627, 589, 12, 1011, 958, 304, 272, 367, 3851, 315, 26177, 26, 267, 340, 2519, 8, 3401, 12, 283, 3058, 297, 488, 304, 288, 3851, 423, 3058, 275, 7531, 8, 3401, 14, 3058, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 2519, 8, 3401, 12, 283, 633, 63, 7435, 297, 12319, 288, 485, 6518, 323, 63, 21801, 8, 3401, 14, 633, 63, 7435, 12, 7531, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 318, 2879, 63, 5245, 8, 1532, 304, 272, 347, 6506, 8, 277, 12, 1067, 304, 267, 2351, 275, 1067, 459, 1069, 2278, 1730, 267, 862, 26, 288, 340, 2351, 459, 6541, 2545, 1078, 63, 509, 418, 1137, 2351, 14, 362, 360, 1418, 735, 355, 746, 4067, 342, 267, 871, 4067, 26, 288, 2351, 459, 6541, 418, 275, 2420, 1078, 63, 509, 582, 2351, 14, 362, 360, 1418, 21004, 398, 790, 275, 2071, 83, 4111, 83, 2, 450, 334, 277, 855, 533, 4914, 578, 3108, 291, 855, 533, 4914, 354, 3368, 267, 340, 790, 440, 315, 2351, 459, 6541, 2565, 288, 2351, 459, 6541, 3488, 498, 61, 275, 2562, 8, 277, 12, 1067, 9, 288, 2351, 14, 5540, 275, 715, 267, 372, 2351, 459, 6541, 3488, 498, 61, 272, 372, 6506, 421, 199, 533, 2832, 20341, 8, 1726, 304, 272, 986, 421, 199, 533, 869, 11925, 7004, 8, 785, 304, 272, 4592, 63, 4423, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 40, 11925, 7004, 12, 291, 2843, 826, 4533, 267, 340, 440, 291, 14, 5464, 26, 288, 746, 11897, 360, 24527, 450, 83, 1471, 1172, 282, 8889, 3530, 4318, 450, 291, 855, 533, 3368, 339, 347, 636, 2975, 721, 277, 304, 267, 536, 275, 2519, 8, 277, 12, 283, 354, 297, 399, 2, 1358, 4579, 450, 83, 2, 450, 291, 855, 533, 4914, 354, 3368, 267, 372, 2649, 8, 354, 9, 339, 347, 485, 362, 63, 885, 63, 20050, 8, 277, 304, 267, 2559, 63, 875, 275, 15671, 904, 8, 277, 855, 578, 4343, 1294, 7563, 4439, 17, 566, 267, 340, 2519, 8, 277, 12, 283, 3603, 297, 488, 304, 288, 862, 26, 355, 3413, 275, 492, 63, 578, 360, 4111, 83, 7, 450, 291, 14, 3603, 12, 2559, 63, 875, 9, 288, 871, 3545, 26, 355, 3413, 275, 492, 63, 578, 8, 277, 14, 3603, 9, 288, 26177, 275, 3413, 14, 20050, 267, 587, 26, 288, 327, 7649, 16306, 282, 8187, 14, 647, 687, 314, 17216, 2559, 288, 340, 859, 63, 1989, 63, 16229, 8, 646, 63, 578, 8, 2491, 63, 875, 395, 283, 3603, 735, 355, 8187, 63, 1494, 275, 492, 63, 578, 5175, 3603, 297, 2559, 63, 875, 9, 355, 26177, 275, 8187, 63, 1494, 14, 20050, 288, 587, 26, 355, 26177, 275, 7970, 8355, 267, 372, 26177, 339, 768, 2732, 63, 5245, 272, 347, 883, 63, 2732, 8, 277, 12, 1067, 304, 267, 408, 1767, 3775, 314, 922, 965, 4719, 4079, 2879, 370, 642, 3931, 14, 398, 961, 1083, 365, 440, 11619, 370, 506, 10087, 14, 267, 710, 754, 402, 314, 1083, 365, 5489, 315, 1126, 13, 1730, 2581, 14, 267, 408, 267, 372, 291, 14, 6541, 8, 1100, 9, 339, 347, 4370, 8, 277, 12, 1067, 304, 267, 408, 11834, 340, 314, 922, 365, 4370, 370, 2879, 642, 3931, 14, 398, 961, 1083, 1077, 506, 10087, 370, 372, 314, 754, 402, 267, 1263, 4592, 5920, 1415, 367, 314, 922, 370, 2879, 642, 3931, 267, 1380, 1655, 6114, 5920, 787, 1415, 14, 267, 408, 267, 372, 291, 423, 2425, 63, 2732, 8, 1100, 459, 1069, 1105, 339, 347, 485, 2425, 63, 2732, 8, 277, 12, 1056, 304, 267, 4592, 63, 1074, 275 ]
[ 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 6906, 314, 6170, 3992, 436, 9330, 626, 7704, 869, 11925, 4052, 652, 365, 14, 199, 2765, 859, 365, 8652, 5007, 12, 436, 1077, 440, 506, 295, 1857, 641, 5370, 14, 199, 199, 9885, 15913, 787, 6326, 2808, 4012, 314, 520, 1494, 1705, 16561, 64, 859, 436, 199, 1589, 3992, 10470, 2337, 262, 14, 199, 624, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 6485, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2190, 14, 3603, 492, 2387, 199, 504, 1639, 14, 2190, 14, 3603, 492, 7970, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 221, 327, 8151, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 23004, 492, 27432, 2141, 199, 504, 1639, 14, 1208, 14, 15481, 492, 5870, 14269, 1692, 221, 327, 8151, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 221, 327, 8151, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 859, 63, 1989, 63, 16229, 221, 327, 8151, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 3743, 199, 504, 21726, 14, 11582, 492, 485, 1818, 63, 3173, 221, 327, 8151, 199, 504, 21726, 14, 11582, 492, 4409, 63, 1178, 221, 327, 8151, 199, 504, 21726, 14, 11582, 492, 4409, 63, 12068, 221, 327, 8151, 199, 504, 21726, 492, 25520, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 485, 6518, 323, 63, 21801, 8, 20050, 12, 7531, 12, 627, 589, 12, 1011, 958, 304, 272, 367, 3851, 315, 26177, 26, 267, 340, 2519, 8, 3401, 12, 283, 3058, 297, 488, 304, 288, 3851, 423, 3058, 275, 7531, 8, 3401, 14, 3058, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 2519, 8, 3401, 12, 283, 633, 63, 7435, 297, 12319, 288, 485, 6518, 323, 63, 21801, 8, 3401, 14, 633, 63, 7435, 12, 7531, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 318, 2879, 63, 5245, 8, 1532, 304, 272, 347, 6506, 8, 277, 12, 1067, 304, 267, 2351, 275, 1067, 459, 1069, 2278, 1730, 267, 862, 26, 288, 340, 2351, 459, 6541, 2545, 1078, 63, 509, 418, 1137, 2351, 14, 362, 360, 1418, 735, 355, 746, 4067, 342, 267, 871, 4067, 26, 288, 2351, 459, 6541, 418, 275, 2420, 1078, 63, 509, 582, 2351, 14, 362, 360, 1418, 21004, 398, 790, 275, 2071, 83, 4111, 83, 2, 450, 334, 277, 855, 533, 4914, 578, 3108, 291, 855, 533, 4914, 354, 3368, 267, 340, 790, 440, 315, 2351, 459, 6541, 2565, 288, 2351, 459, 6541, 3488, 498, 61, 275, 2562, 8, 277, 12, 1067, 9, 288, 2351, 14, 5540, 275, 715, 267, 372, 2351, 459, 6541, 3488, 498, 61, 272, 372, 6506, 421, 199, 533, 2832, 20341, 8, 1726, 304, 272, 986, 421, 199, 533, 869, 11925, 7004, 8, 785, 304, 272, 4592, 63, 4423, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 40, 11925, 7004, 12, 291, 2843, 826, 4533, 267, 340, 440, 291, 14, 5464, 26, 288, 746, 11897, 360, 24527, 450, 83, 1471, 1172, 282, 8889, 3530, 4318, 450, 291, 855, 533, 3368, 339, 347, 636, 2975, 721, 277, 304, 267, 536, 275, 2519, 8, 277, 12, 283, 354, 297, 399, 2, 1358, 4579, 450, 83, 2, 450, 291, 855, 533, 4914, 354, 3368, 267, 372, 2649, 8, 354, 9, 339, 347, 485, 362, 63, 885, 63, 20050, 8, 277, 304, 267, 2559, 63, 875, 275, 15671, 904, 8, 277, 855, 578, 4343, 1294, 7563, 4439, 17, 566, 267, 340, 2519, 8, 277, 12, 283, 3603, 297, 488, 304, 288, 862, 26, 355, 3413, 275, 492, 63, 578, 360, 4111, 83, 7, 450, 291, 14, 3603, 12, 2559, 63, 875, 9, 288, 871, 3545, 26, 355, 3413, 275, 492, 63, 578, 8, 277, 14, 3603, 9, 288, 26177, 275, 3413, 14, 20050, 267, 587, 26, 288, 327, 7649, 16306, 282, 8187, 14, 647, 687, 314, 17216, 2559, 288, 340, 859, 63, 1989, 63, 16229, 8, 646, 63, 578, 8, 2491, 63, 875, 395, 283, 3603, 735, 355, 8187, 63, 1494, 275, 492, 63, 578, 5175, 3603, 297, 2559, 63, 875, 9, 355, 26177, 275, 8187, 63, 1494, 14, 20050, 288, 587, 26, 355, 26177, 275, 7970, 8355, 267, 372, 26177, 339, 768, 2732, 63, 5245, 272, 347, 883, 63, 2732, 8, 277, 12, 1067, 304, 267, 408, 1767, 3775, 314, 922, 965, 4719, 4079, 2879, 370, 642, 3931, 14, 398, 961, 1083, 365, 440, 11619, 370, 506, 10087, 14, 267, 710, 754, 402, 314, 1083, 365, 5489, 315, 1126, 13, 1730, 2581, 14, 267, 408, 267, 372, 291, 14, 6541, 8, 1100, 9, 339, 347, 4370, 8, 277, 12, 1067, 304, 267, 408, 11834, 340, 314, 922, 365, 4370, 370, 2879, 642, 3931, 14, 398, 961, 1083, 1077, 506, 10087, 370, 372, 314, 754, 402, 267, 1263, 4592, 5920, 1415, 367, 314, 922, 370, 2879, 642, 3931, 267, 1380, 1655, 6114, 5920, 787, 1415, 14, 267, 408, 267, 372, 291, 423, 2425, 63, 2732, 8, 1100, 459, 1069, 1105, 339, 347, 485, 2425, 63, 2732, 8, 277, 12, 1056, 304, 267, 4592, 63, 1074, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
joone/chromium-crosswalk
chrome/common/extensions/docs/server2/caching_rietveld_patcher.py
121
4228
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from datetime import datetime, timedelta from file_system import FileNotFoundError from future import Future from patcher import Patcher _VERSION_CACHE_MAXAGE = timedelta(seconds=5) ''' Append @version for keys to distinguish between different patchsets of an issue. ''' def _MakeKey(path, version): return '%s@%s' % (path, version) def _ToObjectStoreValue(raw_value, version): return dict((_MakeKey(key, version), raw_value[key]) for key in raw_value) def _FromObjectStoreValue(raw_value): return dict((key[0:key.rfind('@')], raw_value[key]) for key in raw_value) class _AsyncUncachedFuture(object): def __init__(self, version, paths, cached_value, missing_paths, fetch_delegate, object_store): self._version = version self._paths = paths self._cached_value = cached_value self._missing_paths = missing_paths self._fetch_delegate = fetch_delegate self._object_store = object_store def Get(self): uncached_value = self._fetch_delegate.Get() self._object_store.SetMulti(_ToObjectStoreValue(uncached_value, self._version)) for path in self._missing_paths: if uncached_value.get(path) is None: raise FileNotFoundError('File %s was not found in the patch.' % path) self._cached_value[path] = uncached_value[path] return self._cached_value class CachingRietveldPatcher(Patcher): ''' CachingRietveldPatcher implements a caching layer on top of |patcher|. In theory, it can be used with any class that implements Patcher. But this class assumes that applying to all patched files at once is more efficient than applying to individual files. ''' def __init__(self, rietveld_patcher, object_store_creator, test_datetime=datetime): self._patcher = rietveld_patcher def create_object_store(category): return object_store_creator.Create( CachingRietveldPatcher, category='%s/%s' % (rietveld_patcher.GetIdentity(), category)) self._version_object_store = create_object_store('version') self._list_object_store = create_object_store('list') self._file_object_store = create_object_store('file') self._datetime = test_datetime def GetVersion(self): key = 'version' value = self._version_object_store.Get(key).Get() if value is not None: version, time = value if self._datetime.now() - time < _VERSION_CACHE_MAXAGE: return version version = self._patcher.GetVersion() self._version_object_store.Set(key, (version, self._datetime.now())) return version def GetPatchedFiles(self, version=None): if version is None: version = self.GetVersion() patched_files = self._list_object_store.Get(version).Get() if patched_files is not None: return patched_files patched_files = self._patcher.GetPatchedFiles(version) self._list_object_store.Set(version, patched_files) return patched_files def Apply(self, paths, file_system, version=None): if version is None: version = self.GetVersion() added, deleted, modified = self.GetPatchedFiles(version) cached_value = _FromObjectStoreValue(self._file_object_store. GetMulti([_MakeKey(path, version) for path in paths]).Get()) missing_paths = list(set(paths) - set(cached_value.keys())) if len(missing_paths) == 0: return Future(value=cached_value) return _AsyncUncachedFuture(version, paths, cached_value, missing_paths, self._patcher.Apply(set(added) | set(modified), None, version), self._file_object_store) def GetIdentity(self): return self._patcher.GetIdentity()
bsd-3-clause
[ 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 570, 63, 2253, 492, 3814, 10870, 199, 504, 6466, 492, 20799, 199, 504, 21198, 492, 19292, 281, 199, 199, 63, 4612, 63, 8677, 63, 4283, 2962, 275, 6871, 8, 4515, 29, 21, 9, 199, 199, 2344, 18726, 768, 1023, 367, 2883, 370, 22237, 3382, 3365, 3371, 2193, 402, 199, 290, 4976, 14, 199, 2344, 199, 318, 485, 5483, 1197, 8, 515, 12, 1015, 304, 523, 372, 1543, 83, 19437, 83, 7, 450, 334, 515, 12, 1015, 9, 199, 199, 318, 485, 1378, 1692, 5502, 1110, 8, 1773, 63, 585, 12, 1015, 304, 523, 372, 1211, 1332, 63, 5483, 1197, 8, 498, 12, 1015, 395, 3066, 63, 585, 59, 498, 566, 1598, 367, 790, 315, 3066, 63, 585, 9, 199, 199, 318, 485, 2532, 1692, 5502, 1110, 8, 1773, 63, 585, 304, 523, 372, 1211, 1332, 498, 59, 16, 26, 498, 14, 14542, 16591, 2665, 3066, 63, 585, 59, 498, 566, 367, 790, 315, 3066, 63, 585, 9, 199, 199, 533, 485, 12807, 1358, 5245, 14224, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2049, 1015, 12, 2049, 3792, 12, 2049, 6328, 63, 585, 12, 2049, 4124, 63, 3771, 12, 2049, 5267, 63, 15286, 12, 2049, 909, 63, 1617, 304, 272, 291, 423, 1023, 275, 1015, 272, 291, 423, 3771, 275, 3792, 272, 291, 423, 5245, 63, 585, 275, 6328, 63, 585, 272, 291, 423, 4752, 63, 3771, 275, 4124, 63, 3771, 272, 291, 423, 3535, 63, 15286, 275, 5267, 63, 15286, 272, 291, 423, 785, 63, 1617, 275, 909, 63, 1617, 819, 347, 2372, 8, 277, 304, 272, 625, 5245, 63, 585, 275, 291, 423, 3535, 63, 15286, 14, 1002, 342, 272, 291, 423, 785, 63, 1617, 14, 1084, 3947, 1547, 1378, 1692, 5502, 1110, 8, 324, 5245, 63, 585, 12, 8105, 291, 423, 1023, 430, 339, 367, 931, 315, 291, 423, 4752, 63, 3771, 26, 489, 340, 625, 5245, 63, 585, 14, 362, 8, 515, 9, 365, 488, 26, 267, 746, 3814, 10870, 360, 1173, 450, 83, 1990, 440, 1911, 315, 314, 3371, 3530, 450, 931, 9, 489, 291, 423, 5245, 63, 585, 59, 515, 61, 275, 625, 5245, 63, 585, 59, 515, 61, 339, 372, 291, 423, 5245, 63, 585, 199, 199, 533, 445, 23302, 50, 14077, 86, 457, 11173, 281, 8, 11173, 281, 304, 523, 1449, 445, 23302, 50, 14077, 86, 457, 11173, 281, 9031, 282, 13627, 4045, 641, 2746, 402, 1204, 11238, 18257, 523, 1010, 30629, 12, 652, 883, 506, 1202, 543, 1263, 1021, 626, 9031, 19292, 281, 14, 11017, 642, 523, 1021, 15194, 626, 18876, 370, 1006, 19483, 1584, 737, 5403, 365, 1655, 13402, 523, 2419, 18876, 370, 8212, 1584, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 2049, 8012, 386, 86, 457, 63, 11238, 12, 2049, 909, 63, 1617, 63, 9986, 12, 2049, 511, 63, 2083, 29, 2083, 304, 272, 291, 423, 11238, 275, 8012, 386, 86, 457, 63, 11238, 272, 347, 1218, 63, 785, 63, 1617, 8, 3710, 304, 489, 372, 909, 63, 1617, 63, 9986, 14, 2499, 8, 881, 445, 23302, 50, 14077, 86, 457, 11173, 281, 12, 881, 4637, 9569, 83, 3149, 83, 7, 450, 334, 322, 386, 86, 457, 63, 11238, 14, 1002, 10193, 1062, 4637, 430, 272, 291, 423, 1023, 63, 785, 63, 1617, 275, 1218, 63, 785, 63, 1617, 360, 1023, 358, 272, 291, 423, 513, 63, 785, 63, 1617, 275, 1218, 63, 785, 63, 1617, 360, 513, 358, 272, 291, 423, 493, 63, 785, 63, 1617, 275, 1218, 63, 785, 63, 1617, 360, 493, 358, 272, 291, 423, 2083, 275, 511, 63, 2083, 819, 347, 2372, 3353, 8, 277, 304, 272, 790, 275, 283, 1023, 7, 272, 574, 275, 291, 423, 1023, 63, 785, 63, 1617, 14, 1002, 8, 498, 680, 1002, 342, 272, 340, 574, 365, 440, 488, 26, 489, 1015, 12, 900, 275, 574, 489, 340, 291, 423, 2083, 14, 2131, 342, 446, 900, 665, 485, 4612, 63, 8677, 63, 4283, 2962, 26, 267, 372, 1015, 339, 1015, 275, 291, 423, 11238, 14, 1002, 3353, 342, 272, 291, 423, 1023, 63, 785, 63, 1617, 14, 1084, 8, 498, 12, 1816, 334, 1023, 12, 291, 423, 2083, 14, 2131, 4059, 272, 372, 1015, 819, 347, 2372, 11173, 379, 5535, 8, 277, 12, 1015, 29, 403, 304, 272, 340, 1015, 365, 488, 26, 489, 1015, 275, 291, 14, 1002, 3353, 342, 272, 19483, 63, 1725, 275, 291, 423, 513, 63, 785, 63, 1617, 14, 1002, 8, 1023, 680, 1002, 342, 272, 340, 19483, 63, 1725, 365, 440, 488, 26, 489, 372, 19483, 63, 1725, 339, 19483, 63, 1725, 275, 291, 423, 11238, 14, 1002, 11173, 379, 5535, 8, 1023, 9, 272, 291, 423, 513, 63, 785, 63, 1617, 14, 1084, 8, 1023, 12, 19483, 63, 1725, 9, 272, 372, 19483, 63, 1725, 819, 347, 14618, 8, 277, 12, 3792, 12, 570, 63, 2253, 12, 1015, 29, 403, 304, 272, 340, 1015, 365, 488, 26, 489, 1015, 275, 291, 14, 1002, 3353, 342, 272, 3483, 12, 5463, 12, 6042, 275, 291, 14, 1002, 11173, 379, 5535, 8, 1023, 9, 272, 6328, 63, 585, 275, 485, 2532, 1692, 5502, 1110, 8, 277, 423, 493, 63, 785, 63, 1617, 14, 267, 2372, 3947, 779, 63, 5483, 1197, 8, 515, 12, 1015, 9, 367, 931, 315, 3792, 6575, 1002, 1012, 272, 4124, 63, 3771, 275, 769, 8, 409, 8, 3771, 9, 446, 663, 8, 5245, 63, 585, 14, 1612, 4059, 272, 340, 822, 8, 4752, 63, 3771, 9, 508, 378, 26, 489, 372, 20799, 8, 585, 29, 5245, 63, 585, 9, 339, 372, 485, 12807, 1358, 5245, 14224, 8, 1023, 12, 1816, 3792, 12, 1816, 6328, 63, 585, 12, 1816, 4124, 63, 3771, 12, 1816, 291, 423, 11238, 14, 16581, 8, 409, 8, 3270, 9, 1204, 663, 8, 5540, 395, 8105, 488, 12, 8105, 1015, 395, 1816, 291, 423, 493, 63, 785, 63, 1617, 9, 819, 347, 2372, 10193, 8, 277, 304, 272, 372 ]
[ 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 570, 63, 2253, 492, 3814, 10870, 199, 504, 6466, 492, 20799, 199, 504, 21198, 492, 19292, 281, 199, 199, 63, 4612, 63, 8677, 63, 4283, 2962, 275, 6871, 8, 4515, 29, 21, 9, 199, 199, 2344, 18726, 768, 1023, 367, 2883, 370, 22237, 3382, 3365, 3371, 2193, 402, 199, 290, 4976, 14, 199, 2344, 199, 318, 485, 5483, 1197, 8, 515, 12, 1015, 304, 523, 372, 1543, 83, 19437, 83, 7, 450, 334, 515, 12, 1015, 9, 199, 199, 318, 485, 1378, 1692, 5502, 1110, 8, 1773, 63, 585, 12, 1015, 304, 523, 372, 1211, 1332, 63, 5483, 1197, 8, 498, 12, 1015, 395, 3066, 63, 585, 59, 498, 566, 1598, 367, 790, 315, 3066, 63, 585, 9, 199, 199, 318, 485, 2532, 1692, 5502, 1110, 8, 1773, 63, 585, 304, 523, 372, 1211, 1332, 498, 59, 16, 26, 498, 14, 14542, 16591, 2665, 3066, 63, 585, 59, 498, 566, 367, 790, 315, 3066, 63, 585, 9, 199, 199, 533, 485, 12807, 1358, 5245, 14224, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2049, 1015, 12, 2049, 3792, 12, 2049, 6328, 63, 585, 12, 2049, 4124, 63, 3771, 12, 2049, 5267, 63, 15286, 12, 2049, 909, 63, 1617, 304, 272, 291, 423, 1023, 275, 1015, 272, 291, 423, 3771, 275, 3792, 272, 291, 423, 5245, 63, 585, 275, 6328, 63, 585, 272, 291, 423, 4752, 63, 3771, 275, 4124, 63, 3771, 272, 291, 423, 3535, 63, 15286, 275, 5267, 63, 15286, 272, 291, 423, 785, 63, 1617, 275, 909, 63, 1617, 819, 347, 2372, 8, 277, 304, 272, 625, 5245, 63, 585, 275, 291, 423, 3535, 63, 15286, 14, 1002, 342, 272, 291, 423, 785, 63, 1617, 14, 1084, 3947, 1547, 1378, 1692, 5502, 1110, 8, 324, 5245, 63, 585, 12, 8105, 291, 423, 1023, 430, 339, 367, 931, 315, 291, 423, 4752, 63, 3771, 26, 489, 340, 625, 5245, 63, 585, 14, 362, 8, 515, 9, 365, 488, 26, 267, 746, 3814, 10870, 360, 1173, 450, 83, 1990, 440, 1911, 315, 314, 3371, 3530, 450, 931, 9, 489, 291, 423, 5245, 63, 585, 59, 515, 61, 275, 625, 5245, 63, 585, 59, 515, 61, 339, 372, 291, 423, 5245, 63, 585, 199, 199, 533, 445, 23302, 50, 14077, 86, 457, 11173, 281, 8, 11173, 281, 304, 523, 1449, 445, 23302, 50, 14077, 86, 457, 11173, 281, 9031, 282, 13627, 4045, 641, 2746, 402, 1204, 11238, 18257, 523, 1010, 30629, 12, 652, 883, 506, 1202, 543, 1263, 1021, 626, 9031, 19292, 281, 14, 11017, 642, 523, 1021, 15194, 626, 18876, 370, 1006, 19483, 1584, 737, 5403, 365, 1655, 13402, 523, 2419, 18876, 370, 8212, 1584, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 2049, 8012, 386, 86, 457, 63, 11238, 12, 2049, 909, 63, 1617, 63, 9986, 12, 2049, 511, 63, 2083, 29, 2083, 304, 272, 291, 423, 11238, 275, 8012, 386, 86, 457, 63, 11238, 272, 347, 1218, 63, 785, 63, 1617, 8, 3710, 304, 489, 372, 909, 63, 1617, 63, 9986, 14, 2499, 8, 881, 445, 23302, 50, 14077, 86, 457, 11173, 281, 12, 881, 4637, 9569, 83, 3149, 83, 7, 450, 334, 322, 386, 86, 457, 63, 11238, 14, 1002, 10193, 1062, 4637, 430, 272, 291, 423, 1023, 63, 785, 63, 1617, 275, 1218, 63, 785, 63, 1617, 360, 1023, 358, 272, 291, 423, 513, 63, 785, 63, 1617, 275, 1218, 63, 785, 63, 1617, 360, 513, 358, 272, 291, 423, 493, 63, 785, 63, 1617, 275, 1218, 63, 785, 63, 1617, 360, 493, 358, 272, 291, 423, 2083, 275, 511, 63, 2083, 819, 347, 2372, 3353, 8, 277, 304, 272, 790, 275, 283, 1023, 7, 272, 574, 275, 291, 423, 1023, 63, 785, 63, 1617, 14, 1002, 8, 498, 680, 1002, 342, 272, 340, 574, 365, 440, 488, 26, 489, 1015, 12, 900, 275, 574, 489, 340, 291, 423, 2083, 14, 2131, 342, 446, 900, 665, 485, 4612, 63, 8677, 63, 4283, 2962, 26, 267, 372, 1015, 339, 1015, 275, 291, 423, 11238, 14, 1002, 3353, 342, 272, 291, 423, 1023, 63, 785, 63, 1617, 14, 1084, 8, 498, 12, 1816, 334, 1023, 12, 291, 423, 2083, 14, 2131, 4059, 272, 372, 1015, 819, 347, 2372, 11173, 379, 5535, 8, 277, 12, 1015, 29, 403, 304, 272, 340, 1015, 365, 488, 26, 489, 1015, 275, 291, 14, 1002, 3353, 342, 272, 19483, 63, 1725, 275, 291, 423, 513, 63, 785, 63, 1617, 14, 1002, 8, 1023, 680, 1002, 342, 272, 340, 19483, 63, 1725, 365, 440, 488, 26, 489, 372, 19483, 63, 1725, 339, 19483, 63, 1725, 275, 291, 423, 11238, 14, 1002, 11173, 379, 5535, 8, 1023, 9, 272, 291, 423, 513, 63, 785, 63, 1617, 14, 1084, 8, 1023, 12, 19483, 63, 1725, 9, 272, 372, 19483, 63, 1725, 819, 347, 14618, 8, 277, 12, 3792, 12, 570, 63, 2253, 12, 1015, 29, 403, 304, 272, 340, 1015, 365, 488, 26, 489, 1015, 275, 291, 14, 1002, 3353, 342, 272, 3483, 12, 5463, 12, 6042, 275, 291, 14, 1002, 11173, 379, 5535, 8, 1023, 9, 272, 6328, 63, 585, 275, 485, 2532, 1692, 5502, 1110, 8, 277, 423, 493, 63, 785, 63, 1617, 14, 267, 2372, 3947, 779, 63, 5483, 1197, 8, 515, 12, 1015, 9, 367, 931, 315, 3792, 6575, 1002, 1012, 272, 4124, 63, 3771, 275, 769, 8, 409, 8, 3771, 9, 446, 663, 8, 5245, 63, 585, 14, 1612, 4059, 272, 340, 822, 8, 4752, 63, 3771, 9, 508, 378, 26, 489, 372, 20799, 8, 585, 29, 5245, 63, 585, 9, 339, 372, 485, 12807, 1358, 5245, 14224, 8, 1023, 12, 1816, 3792, 12, 1816, 6328, 63, 585, 12, 1816, 4124, 63, 3771, 12, 1816, 291, 423, 11238, 14, 16581, 8, 409, 8, 3270, 9, 1204, 663, 8, 5540, 395, 8105, 488, 12, 8105, 1015, 395, 1816, 291, 423, 493, 63, 785, 63, 1617, 9, 819, 347, 2372, 10193, 8, 277, 304, 272, 372, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pacav69/namebench
nb_third_party/dns/rdtypes/IN/NAPTR.py
248
4889
# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, # provided that the above copyright notice and this permission notice # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import struct import dns.exception import dns.name import dns.rdata def _write_string(file, s): l = len(s) assert l < 256 byte = chr(l) file.write(byte) file.write(s) class NAPTR(dns.rdata.Rdata): """NAPTR record @ivar order: order @type order: int @ivar preference: preference @type preference: int @ivar flags: flags @type flags: string @ivar service: service @type service: string @ivar regexp: regular expression @type regexp: string @ivar replacement: replacement name @type replacement: dns.name.Name object @see: RFC 3403""" __slots__ = ['order', 'preference', 'flags', 'service', 'regexp', 'replacement'] def __init__(self, rdclass, rdtype, order, preference, flags, service, regexp, replacement): super(NAPTR, self).__init__(rdclass, rdtype) self.order = order self.preference = preference self.flags = flags self.service = service self.regexp = regexp self.replacement = replacement def to_text(self, origin=None, relativize=True, **kw): replacement = self.replacement.choose_relativity(origin, relativize) return '%d %d "%s" "%s" "%s" %s' % \ (self.order, self.preference, dns.rdata._escapify(self.flags), dns.rdata._escapify(self.service), dns.rdata._escapify(self.regexp), self.replacement) def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): order = tok.get_uint16() preference = tok.get_uint16() flags = tok.get_string() service = tok.get_string() regexp = tok.get_string() replacement = tok.get_name() replacement = replacement.choose_relativity(origin, relativize) tok.get_eol() return cls(rdclass, rdtype, order, preference, flags, service, regexp, replacement) from_text = classmethod(from_text) def to_wire(self, file, compress = None, origin = None): two_ints = struct.pack("!HH", self.order, self.preference) file.write(two_ints) _write_string(file, self.flags) _write_string(file, self.service) _write_string(file, self.regexp) self.replacement.to_wire(file, compress, origin) def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None): (order, preference) = struct.unpack('!HH', wire[current : current + 4]) current += 4 rdlen -= 4 strings = [] for i in xrange(3): l = ord(wire[current]) current += 1 rdlen -= 1 if l > rdlen or rdlen < 0: raise dns.exception.FormError s = wire[current : current + l] current += l rdlen -= l strings.append(s) (replacement, cused) = dns.name.from_wire(wire[: current + rdlen], current) if cused != rdlen: raise dns.exception.FormError if not origin is None: replacement = replacement.relativize(origin) return cls(rdclass, rdtype, order, preference, strings[0], strings[1], strings[2], replacement) from_wire = classmethod(from_wire) def choose_relativity(self, origin = None, relativize = True): self.replacement = self.replacement.choose_relativity(origin, relativize) def _cmp(self, other): sp = struct.pack("!HH", self.order, self.preference) op = struct.pack("!HH", other.order, other.preference) v = cmp(sp, op) if v == 0: v = cmp(self.flags, other.flags) if v == 0: v = cmp(self.service, other.service) if v == 0: v = cmp(self.regexp, other.regexp) if v == 0: v = cmp(self.replacement, other.replacement) return v
apache-2.0
[ 3, 1898, 334, 35, 9, 13004, 13, 9488, 12, 8937, 12, 7129, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 646, 2702, 199, 199, 646, 6715, 14, 1971, 199, 646, 6715, 14, 354, 199, 646, 6715, 14, 23203, 199, 199, 318, 485, 952, 63, 875, 8, 493, 12, 308, 304, 272, 634, 275, 822, 8, 83, 9, 272, 702, 634, 665, 7633, 272, 3696, 275, 8678, 8, 76, 9, 272, 570, 14, 952, 8, 4414, 9, 272, 570, 14, 952, 8, 83, 9, 199, 199, 533, 653, 1282, 1766, 8, 5797, 14, 23203, 14, 50, 576, 304, 272, 408, 46, 1282, 1766, 2777, 339, 768, 7725, 1865, 26, 1865, 272, 768, 466, 1865, 26, 1109, 272, 768, 7725, 16705, 26, 16705, 272, 768, 466, 16705, 26, 1109, 272, 768, 7725, 3285, 26, 3285, 272, 768, 466, 3285, 26, 1059, 272, 768, 7725, 2435, 26, 2435, 272, 768, 466, 2435, 26, 1059, 272, 768, 7725, 13156, 26, 5578, 3965, 272, 768, 466, 13156, 26, 1059, 272, 768, 7725, 8343, 26, 8343, 536, 272, 768, 466, 8343, 26, 6715, 14, 354, 14, 985, 909, 272, 768, 3239, 26, 7329, 8177, 1644, 624, 339, 636, 7257, 363, 275, 788, 1648, 297, 283, 14994, 297, 283, 2469, 297, 283, 1364, 297, 283, 11191, 297, 326, 283, 15895, 418, 2286, 347, 636, 826, 721, 277, 12, 29320, 12, 22764, 12, 1865, 12, 16705, 12, 3285, 12, 2435, 12, 326, 13156, 12, 8343, 304, 267, 1613, 8, 46, 1282, 1766, 12, 291, 2843, 826, 721, 30186, 12, 22764, 9, 267, 291, 14, 1648, 275, 1865, 267, 291, 14, 14994, 275, 16705, 267, 291, 14, 2469, 275, 3285, 267, 291, 14, 1364, 275, 2435, 267, 291, 14, 11191, 275, 13156, 267, 291, 14, 15895, 275, 8343, 339, 347, 370, 63, 505, 8, 277, 12, 6330, 29, 403, 12, 13773, 29282, 29, 549, 12, 1011, 829, 304, 267, 8343, 275, 291, 14, 15895, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 372, 1543, 68, 450, 68, 2071, 83, 2, 2071, 83, 2, 2071, 83, 2, 450, 83, 7, 450, 971, 2049, 334, 277, 14, 1648, 12, 291, 14, 14994, 12, 355, 6715, 14, 23203, 423, 24698, 2021, 8, 277, 14, 2469, 395, 355, 6715, 14, 23203, 423, 24698, 2021, 8, 277, 14, 1364, 395, 355, 6715, 14, 23203, 423, 24698, 2021, 8, 277, 14, 11191, 395, 355, 291, 14, 15895, 9, 339, 347, 687, 63, 505, 8, 1886, 12, 29320, 12, 22764, 12, 8431, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 1865, 275, 8431, 14, 362, 63, 1635, 975, 342, 267, 16705, 275, 8431, 14, 362, 63, 1635, 975, 342, 267, 3285, 275, 8431, 14, 362, 63, 875, 342, 267, 2435, 275, 8431, 14, 362, 63, 875, 342, 267, 13156, 275, 8431, 14, 362, 63, 875, 342, 267, 8343, 275, 8431, 14, 362, 63, 354, 342, 267, 8343, 275, 8343, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 8431, 14, 362, 63, 20470, 342, 267, 372, 843, 8, 30186, 12, 22764, 12, 1865, 12, 16705, 12, 3285, 12, 2435, 12, 673, 13156, 12, 8343, 9, 2286, 687, 63, 505, 275, 18990, 8, 504, 63, 505, 9, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 2877, 63, 13141, 275, 2702, 14, 1389, 19232, 10213, 401, 291, 14, 1648, 12, 291, 14, 14994, 9, 267, 570, 14, 952, 8, 5601, 63, 13141, 9, 267, 485, 952, 63, 875, 8, 493, 12, 291, 14, 2469, 9, 267, 485, 952, 63, 875, 8, 493, 12, 291, 14, 1364, 9, 267, 485, 952, 63, 875, 8, 493, 12, 291, 14, 11191, 9, 267, 291, 14, 15895, 14, 475, 63, 11239, 8, 493, 12, 11029, 12, 6330, 9, 5493, 347, 687, 63, 11239, 8, 1886, 12, 29320, 12, 22764, 12, 11799, 12, 1453, 12, 11517, 552, 12, 6330, 275, 488, 304, 267, 334, 1648, 12, 16705, 9, 275, 2702, 14, 5301, 16157, 10213, 297, 11799, 59, 1818, 520, 1453, 435, 841, 566, 267, 1453, 847, 841, 267, 11517, 552, 4862, 841, 267, 3326, 275, 942, 267, 367, 284, 315, 4945, 8, 19, 304, 288, 634, 275, 6206, 8, 11239, 59, 1818, 566, 288, 1453, 847, 413, 288, 11517, 552, 4862, 413, 288, 340, 634, 690, 11517, 552, 503, 11517, 552, 665, 378, 26, 355, 746, 6715, 14, 1971, 14, 2821, 547, 288, 308, 275, 11799, 59, 1818, 520, 1453, 435, 634, 61, 288, 1453, 847, 634, 288, 11517, 552, 4862, 634, 288, 3326, 14, 740, 8, 83, 9, 267, 334, 15895, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 8179, 1453, 9, 267, 340, 286, 2972, 1137, 11517, 552, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 340, 440, 6330, 365, 488, 26, 288, 8343, 275, 8343, 14, 17060, 29282, 8, 6493, 9, 267, 372, 843, 8, 30186, 12, 22764, 12, 1865, 12, 16705, 12, 3326, 59, 16, 467, 3326, 59, 17, 467, 673, 3326, 59, 18, 467, 8343, 9, 339, 687, 63, 11239, 275, 18990, 8, 504, 63, 11239, 9, 339, 347, 11496, 63 ]
[ 1898, 334, 35, 9, 13004, 13, 9488, 12, 8937, 12, 7129, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 646, 2702, 199, 199, 646, 6715, 14, 1971, 199, 646, 6715, 14, 354, 199, 646, 6715, 14, 23203, 199, 199, 318, 485, 952, 63, 875, 8, 493, 12, 308, 304, 272, 634, 275, 822, 8, 83, 9, 272, 702, 634, 665, 7633, 272, 3696, 275, 8678, 8, 76, 9, 272, 570, 14, 952, 8, 4414, 9, 272, 570, 14, 952, 8, 83, 9, 199, 199, 533, 653, 1282, 1766, 8, 5797, 14, 23203, 14, 50, 576, 304, 272, 408, 46, 1282, 1766, 2777, 339, 768, 7725, 1865, 26, 1865, 272, 768, 466, 1865, 26, 1109, 272, 768, 7725, 16705, 26, 16705, 272, 768, 466, 16705, 26, 1109, 272, 768, 7725, 3285, 26, 3285, 272, 768, 466, 3285, 26, 1059, 272, 768, 7725, 2435, 26, 2435, 272, 768, 466, 2435, 26, 1059, 272, 768, 7725, 13156, 26, 5578, 3965, 272, 768, 466, 13156, 26, 1059, 272, 768, 7725, 8343, 26, 8343, 536, 272, 768, 466, 8343, 26, 6715, 14, 354, 14, 985, 909, 272, 768, 3239, 26, 7329, 8177, 1644, 624, 339, 636, 7257, 363, 275, 788, 1648, 297, 283, 14994, 297, 283, 2469, 297, 283, 1364, 297, 283, 11191, 297, 326, 283, 15895, 418, 2286, 347, 636, 826, 721, 277, 12, 29320, 12, 22764, 12, 1865, 12, 16705, 12, 3285, 12, 2435, 12, 326, 13156, 12, 8343, 304, 267, 1613, 8, 46, 1282, 1766, 12, 291, 2843, 826, 721, 30186, 12, 22764, 9, 267, 291, 14, 1648, 275, 1865, 267, 291, 14, 14994, 275, 16705, 267, 291, 14, 2469, 275, 3285, 267, 291, 14, 1364, 275, 2435, 267, 291, 14, 11191, 275, 13156, 267, 291, 14, 15895, 275, 8343, 339, 347, 370, 63, 505, 8, 277, 12, 6330, 29, 403, 12, 13773, 29282, 29, 549, 12, 1011, 829, 304, 267, 8343, 275, 291, 14, 15895, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 372, 1543, 68, 450, 68, 2071, 83, 2, 2071, 83, 2, 2071, 83, 2, 450, 83, 7, 450, 971, 2049, 334, 277, 14, 1648, 12, 291, 14, 14994, 12, 355, 6715, 14, 23203, 423, 24698, 2021, 8, 277, 14, 2469, 395, 355, 6715, 14, 23203, 423, 24698, 2021, 8, 277, 14, 1364, 395, 355, 6715, 14, 23203, 423, 24698, 2021, 8, 277, 14, 11191, 395, 355, 291, 14, 15895, 9, 339, 347, 687, 63, 505, 8, 1886, 12, 29320, 12, 22764, 12, 8431, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 1865, 275, 8431, 14, 362, 63, 1635, 975, 342, 267, 16705, 275, 8431, 14, 362, 63, 1635, 975, 342, 267, 3285, 275, 8431, 14, 362, 63, 875, 342, 267, 2435, 275, 8431, 14, 362, 63, 875, 342, 267, 13156, 275, 8431, 14, 362, 63, 875, 342, 267, 8343, 275, 8431, 14, 362, 63, 354, 342, 267, 8343, 275, 8343, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 8431, 14, 362, 63, 20470, 342, 267, 372, 843, 8, 30186, 12, 22764, 12, 1865, 12, 16705, 12, 3285, 12, 2435, 12, 673, 13156, 12, 8343, 9, 2286, 687, 63, 505, 275, 18990, 8, 504, 63, 505, 9, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 2877, 63, 13141, 275, 2702, 14, 1389, 19232, 10213, 401, 291, 14, 1648, 12, 291, 14, 14994, 9, 267, 570, 14, 952, 8, 5601, 63, 13141, 9, 267, 485, 952, 63, 875, 8, 493, 12, 291, 14, 2469, 9, 267, 485, 952, 63, 875, 8, 493, 12, 291, 14, 1364, 9, 267, 485, 952, 63, 875, 8, 493, 12, 291, 14, 11191, 9, 267, 291, 14, 15895, 14, 475, 63, 11239, 8, 493, 12, 11029, 12, 6330, 9, 5493, 347, 687, 63, 11239, 8, 1886, 12, 29320, 12, 22764, 12, 11799, 12, 1453, 12, 11517, 552, 12, 6330, 275, 488, 304, 267, 334, 1648, 12, 16705, 9, 275, 2702, 14, 5301, 16157, 10213, 297, 11799, 59, 1818, 520, 1453, 435, 841, 566, 267, 1453, 847, 841, 267, 11517, 552, 4862, 841, 267, 3326, 275, 942, 267, 367, 284, 315, 4945, 8, 19, 304, 288, 634, 275, 6206, 8, 11239, 59, 1818, 566, 288, 1453, 847, 413, 288, 11517, 552, 4862, 413, 288, 340, 634, 690, 11517, 552, 503, 11517, 552, 665, 378, 26, 355, 746, 6715, 14, 1971, 14, 2821, 547, 288, 308, 275, 11799, 59, 1818, 520, 1453, 435, 634, 61, 288, 1453, 847, 634, 288, 11517, 552, 4862, 634, 288, 3326, 14, 740, 8, 83, 9, 267, 334, 15895, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 8179, 1453, 9, 267, 340, 286, 2972, 1137, 11517, 552, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 340, 440, 6330, 365, 488, 26, 288, 8343, 275, 8343, 14, 17060, 29282, 8, 6493, 9, 267, 372, 843, 8, 30186, 12, 22764, 12, 1865, 12, 16705, 12, 3326, 59, 16, 467, 3326, 59, 17, 467, 673, 3326, 59, 18, 467, 8343, 9, 339, 687, 63, 11239, 275, 18990, 8, 504, 63, 11239, 9, 339, 347, 11496, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
googleapis/googleapis-gen
google/ads/googleads/v8/googleads-py/google/ads/googleads/v8/common/types/ad_type_infos.py
1
46175
# -*- coding: utf-8 -*- # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import proto # type: ignore from google.ads.googleads.v8.common.types import ad_asset from google.ads.googleads.v8.enums.types import call_conversion_reporting_state from google.ads.googleads.v8.enums.types import display_ad_format_setting from google.ads.googleads.v8.enums.types import display_upload_product_type as gage_display_upload_product_type from google.ads.googleads.v8.enums.types import legacy_app_install_ad_app_store from google.ads.googleads.v8.enums.types import mime_type as gage_mime_type __protobuf__ = proto.module( package='google.ads.googleads.v8.common', marshal='google.ads.googleads.v8', manifest={ 'TextAdInfo', 'ExpandedTextAdInfo', 'ExpandedDynamicSearchAdInfo', 'HotelAdInfo', 'ShoppingSmartAdInfo', 'ShoppingProductAdInfo', 'ShoppingComparisonListingAdInfo', 'GmailAdInfo', 'GmailTeaser', 'DisplayCallToAction', 'ProductImage', 'ProductVideo', 'ImageAdInfo', 'VideoBumperInStreamAdInfo', 'VideoNonSkippableInStreamAdInfo', 'VideoTrueViewInStreamAdInfo', 'VideoOutstreamAdInfo', 'VideoTrueViewDiscoveryAdInfo', 'VideoAdInfo', 'VideoResponsiveAdInfo', 'ResponsiveSearchAdInfo', 'LegacyResponsiveDisplayAdInfo', 'AppAdInfo', 'AppEngagementAdInfo', 'LegacyAppInstallAdInfo', 'ResponsiveDisplayAdInfo', 'LocalAdInfo', 'DisplayUploadAdInfo', 'ResponsiveDisplayAdControlSpec', 'SmartCampaignAdInfo', 'CallAdInfo', }, ) class TextAdInfo(proto.Message): r"""A text ad. Attributes: headline (str): The headline of the ad. description1 (str): The first line of the ad's description. description2 (str): The second line of the ad's description. """ headline = proto.Field( proto.STRING, number=4, optional=True, ) description1 = proto.Field( proto.STRING, number=5, optional=True, ) description2 = proto.Field( proto.STRING, number=6, optional=True, ) class ExpandedTextAdInfo(proto.Message): r"""An expanded text ad. Attributes: headline_part1 (str): The first part of the ad's headline. headline_part2 (str): The second part of the ad's headline. headline_part3 (str): The third part of the ad's headline. description (str): The description of the ad. description2 (str): The second description of the ad. path1 (str): The text that can appear alongside the ad's displayed URL. path2 (str): Additional text that can appear alongside the ad's displayed URL. """ headline_part1 = proto.Field( proto.STRING, number=8, optional=True, ) headline_part2 = proto.Field( proto.STRING, number=9, optional=True, ) headline_part3 = proto.Field( proto.STRING, number=10, optional=True, ) description = proto.Field( proto.STRING, number=11, optional=True, ) description2 = proto.Field( proto.STRING, number=12, optional=True, ) path1 = proto.Field( proto.STRING, number=13, optional=True, ) path2 = proto.Field( proto.STRING, number=14, optional=True, ) class ExpandedDynamicSearchAdInfo(proto.Message): r"""An expanded dynamic search ad. Attributes: description (str): The description of the ad. description2 (str): The second description of the ad. """ description = proto.Field( proto.STRING, number=3, optional=True, ) description2 = proto.Field( proto.STRING, number=4, optional=True, ) class HotelAdInfo(proto.Message): r"""A hotel ad. """ class ShoppingSmartAdInfo(proto.Message): r"""A Smart Shopping ad. """ class ShoppingProductAdInfo(proto.Message): r"""A standard Shopping ad. """ class ShoppingComparisonListingAdInfo(proto.Message): r"""A Shopping Comparison Listing ad. Attributes: headline (str): Headline of the ad. This field is required. Allowed length is between 25 and 45 characters. """ headline = proto.Field( proto.STRING, number=2, optional=True, ) class GmailAdInfo(proto.Message): r"""A Gmail ad. Attributes: teaser (google.ads.googleads.v8.common.types.GmailTeaser): The Gmail teaser. header_image (str): The MediaFile resource name of the header image. Valid image types are GIF, JPEG and PNG. The minimum size is 300x100 pixels and the aspect ratio must be between 3:1 and 5:1 (+-1%). marketing_image (str): The MediaFile resource name of the marketing image. Valid image types are GIF, JPEG and PNG. The image must either be landscape with a minimum size of 600x314 pixels and aspect ratio of 600:314 (+-1%) or square with a minimum size of 300x300 pixels and aspect ratio of 1:1 (+-1%) marketing_image_headline (str): Headline of the marketing image. marketing_image_description (str): Description of the marketing image. marketing_image_display_call_to_action (google.ads.googleads.v8.common.types.DisplayCallToAction): Display-call-to-action of the marketing image. product_images (Sequence[google.ads.googleads.v8.common.types.ProductImage]): Product images. Up to 15 images are supported. product_videos (Sequence[google.ads.googleads.v8.common.types.ProductVideo]): Product videos. Up to 7 videos are supported. At least one product video or a marketing image must be specified. """ teaser = proto.Field( proto.MESSAGE, number=1, message='GmailTeaser', ) header_image = proto.Field( proto.STRING, number=10, optional=True, ) marketing_image = proto.Field( proto.STRING, number=11, optional=True, ) marketing_image_headline = proto.Field( proto.STRING, number=12, optional=True, ) marketing_image_description = proto.Field( proto.STRING, number=13, optional=True, ) marketing_image_display_call_to_action = proto.Field( proto.MESSAGE, number=6, message='DisplayCallToAction', ) product_images = proto.RepeatedField( proto.MESSAGE, number=7, message='ProductImage', ) product_videos = proto.RepeatedField( proto.MESSAGE, number=8, message='ProductVideo', ) class GmailTeaser(proto.Message): r"""Gmail teaser data. The teaser is a small header that acts as an invitation to view the rest of the ad (the body). Attributes: headline (str): Headline of the teaser. description (str): Description of the teaser. business_name (str): Business name of the advertiser. logo_image (str): The MediaFile resource name of the logo image. Valid image types are GIF, JPEG and PNG. The minimum size is 144x144 pixels and the aspect ratio must be 1:1 (+-1%). """ headline = proto.Field( proto.STRING, number=5, optional=True, ) description = proto.Field( proto.STRING, number=6, optional=True, ) business_name = proto.Field( proto.STRING, number=7, optional=True, ) logo_image = proto.Field( proto.STRING, number=8, optional=True, ) class DisplayCallToAction(proto.Message): r"""Data for display call to action. The call to action is a piece of the ad that prompts the user to do something. Like clicking a link or making a phone call. Attributes: text (str): Text for the display-call-to-action. text_color (str): Text color for the display-call-to-action in hexadecimal, e.g. #ffffff for white. url_collection_id (str): Identifies the url collection in the ad.url_collections field. If not set the url defaults to final_url. """ text = proto.Field( proto.STRING, number=5, optional=True, ) text_color = proto.Field( proto.STRING, number=6, optional=True, ) url_collection_id = proto.Field( proto.STRING, number=7, optional=True, ) class ProductImage(proto.Message): r"""Product image specific data. Attributes: product_image (str): The MediaFile resource name of the product image. Valid image types are GIF, JPEG and PNG. The minimum size is 300x300 pixels and the aspect ratio must be 1:1 (+-1%). description (str): Description of the product. display_call_to_action (google.ads.googleads.v8.common.types.DisplayCallToAction): Display-call-to-action of the product image. """ product_image = proto.Field( proto.STRING, number=4, optional=True, ) description = proto.Field( proto.STRING, number=5, optional=True, ) display_call_to_action = proto.Field( proto.MESSAGE, number=3, message='DisplayCallToAction', ) class ProductVideo(proto.Message): r"""Product video specific data. Attributes: product_video (str): The MediaFile resource name of a video which must be hosted on YouTube. """ product_video = proto.Field( proto.STRING, number=2, optional=True, ) class ImageAdInfo(proto.Message): r"""An image ad. Attributes: pixel_width (int): Width in pixels of the full size image. pixel_height (int): Height in pixels of the full size image. image_url (str): URL of the full size image. preview_pixel_width (int): Width in pixels of the preview size image. preview_pixel_height (int): Height in pixels of the preview size image. preview_image_url (str): URL of the preview size image. mime_type (google.ads.googleads.v8.enums.types.MimeTypeEnum.MimeType): The mime type of the image. name (str): The name of the image. If the image was created from a MediaFile, this is the MediaFile's name. If the image was created from bytes, this is empty. media_file (str): The MediaFile resource to use for the image. data (bytes): Raw image data as bytes. ad_id_to_copy_image_from (int): An ad ID to copy the image from. """ pixel_width = proto.Field( proto.INT64, number=15, optional=True, ) pixel_height = proto.Field( proto.INT64, number=16, optional=True, ) image_url = proto.Field( proto.STRING, number=17, optional=True, ) preview_pixel_width = proto.Field( proto.INT64, number=18, optional=True, ) preview_pixel_height = proto.Field( proto.INT64, number=19, optional=True, ) preview_image_url = proto.Field( proto.STRING, number=20, optional=True, ) mime_type = proto.Field( proto.ENUM, number=10, enum=gage_mime_type.MimeTypeEnum.MimeType, ) name = proto.Field( proto.STRING, number=21, optional=True, ) media_file = proto.Field( proto.STRING, number=12, oneof='image', ) data = proto.Field( proto.BYTES, number=13, oneof='image', ) ad_id_to_copy_image_from = proto.Field( proto.INT64, number=14, oneof='image', ) class VideoBumperInStreamAdInfo(proto.Message): r"""Representation of video bumper in-stream ad format (very short in-stream non-skippable video ad). Attributes: companion_banner (str): The MediaFile resource name of the companion banner used with the ad. """ companion_banner = proto.Field( proto.STRING, number=2, optional=True, ) class VideoNonSkippableInStreamAdInfo(proto.Message): r"""Representation of video non-skippable in-stream ad format (15 second in-stream non-skippable video ad). Attributes: companion_banner (str): The MediaFile resource name of the companion banner used with the ad. """ companion_banner = proto.Field( proto.STRING, number=2, optional=True, ) class VideoTrueViewInStreamAdInfo(proto.Message): r"""Representation of video TrueView in-stream ad format (ad shown during video playback, often at beginning, which displays a skip button a few seconds into the video). Attributes: action_button_label (str): Label on the CTA (call-to-action) button taking the user to the video ad's final URL. Required for TrueView for action campaigns, optional otherwise. action_headline (str): Additional text displayed with the CTA (call- o-action) button to give context and encourage clicking on the button. companion_banner (str): The MediaFile resource name of the companion banner used with the ad. """ action_button_label = proto.Field( proto.STRING, number=4, optional=True, ) action_headline = proto.Field( proto.STRING, number=5, optional=True, ) companion_banner = proto.Field( proto.STRING, number=6, optional=True, ) class VideoOutstreamAdInfo(proto.Message): r"""Representation of video out-stream ad format (ad shown alongside a feed with automatic playback, without sound). Attributes: headline (str): The headline of the ad. description (str): The description line. """ headline = proto.Field( proto.STRING, number=3, optional=True, ) description = proto.Field( proto.STRING, number=4, optional=True, ) class VideoTrueViewDiscoveryAdInfo(proto.Message): r"""Representation of video TrueView discovery ad format. Attributes: headline (str): The headline of the ad. description1 (str): First text line for a TrueView video discovery ad. description2 (str): Second text line for a TrueView video discovery ad. """ headline = proto.Field( proto.STRING, number=4, optional=True, ) description1 = proto.Field( proto.STRING, number=5, optional=True, ) description2 = proto.Field( proto.STRING, number=6, optional=True, ) class VideoAdInfo(proto.Message): r"""A video ad. Attributes: media_file (str): The MediaFile resource to use for the video. in_stream (google.ads.googleads.v8.common.types.VideoTrueViewInStreamAdInfo): Video TrueView in-stream ad format. bumper (google.ads.googleads.v8.common.types.VideoBumperInStreamAdInfo): Video bumper in-stream ad format. out_stream (google.ads.googleads.v8.common.types.VideoOutstreamAdInfo): Video out-stream ad format. non_skippable (google.ads.googleads.v8.common.types.VideoNonSkippableInStreamAdInfo): Video non-skippable in-stream ad format. discovery (google.ads.googleads.v8.common.types.VideoTrueViewDiscoveryAdInfo): Video TrueView discovery ad format. """ media_file = proto.Field( proto.STRING, number=7, optional=True, ) in_stream = proto.Field( proto.MESSAGE, number=2, oneof='format', message='VideoTrueViewInStreamAdInfo', ) bumper = proto.Field( proto.MESSAGE, number=3, oneof='format', message='VideoBumperInStreamAdInfo', ) out_stream = proto.Field( proto.MESSAGE, number=4, oneof='format', message='VideoOutstreamAdInfo', ) non_skippable = proto.Field( proto.MESSAGE, number=5, oneof='format', message='VideoNonSkippableInStreamAdInfo', ) discovery = proto.Field( proto.MESSAGE, number=6, oneof='format', message='VideoTrueViewDiscoveryAdInfo', ) class VideoResponsiveAdInfo(proto.Message): r"""A video responsive ad. Attributes: headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets used for the short headline, e.g. the "Call To Action" banner. Currently, only a single value for the short headline is supported. long_headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets used for the long headline. Currently, only a single value for the long headline is supported. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets used for the description. Currently, only a single value for the description is supported. call_to_actions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets used for the button, e.g. the "Call To Action" button. Currently, only a single value for the button is supported. videos (Sequence[google.ads.googleads.v8.common.types.AdVideoAsset]): List of YouTube video assets used for the ad. Currently, only a single value for the YouTube video asset is supported. companion_banners (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): List of image assets used for the companion banner. Currently, only a single value for the companion banner asset is supported. """ headlines = proto.RepeatedField( proto.MESSAGE, number=1, message=ad_asset.AdTextAsset, ) long_headlines = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=3, message=ad_asset.AdTextAsset, ) call_to_actions = proto.RepeatedField( proto.MESSAGE, number=4, message=ad_asset.AdTextAsset, ) videos = proto.RepeatedField( proto.MESSAGE, number=5, message=ad_asset.AdVideoAsset, ) companion_banners = proto.RepeatedField( proto.MESSAGE, number=6, message=ad_asset.AdImageAsset, ) class ResponsiveSearchAdInfo(proto.Message): r"""A responsive search ad. Responsive search ads let you create an ad that adapts to show more text, and more relevant messages, to your customers. Enter multiple headlines and descriptions when creating a responsive search ad, and over time, Google Ads will automatically test different combinations and learn which combinations perform best. By adapting your ad's content to more closely match potential customers' search terms, responsive search ads may improve your campaign's performance. More information at https://support.google.com/google- ads/answer/7684791 Attributes: headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for headlines. When the ad serves the headlines will be selected from this list. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for descriptions. When the ad serves the descriptions will be selected from this list. path1 (str): First part of text that may appear appended to the url displayed in the ad. path2 (str): Second part of text that may appear appended to the url displayed in the ad. This field can only be set when path1 is also set. """ headlines = proto.RepeatedField( proto.MESSAGE, number=1, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdTextAsset, ) path1 = proto.Field( proto.STRING, number=5, optional=True, ) path2 = proto.Field( proto.STRING, number=6, optional=True, ) class LegacyResponsiveDisplayAdInfo(proto.Message): r"""A legacy responsive display ad. Ads of this type are labeled 'Responsive ads' in the Google Ads UI. Attributes: short_headline (str): The short version of the ad's headline. long_headline (str): The long version of the ad's headline. description (str): The description of the ad. business_name (str): The business name in the ad. allow_flexible_color (bool): Advertiser's consent to allow flexible color. When true, the ad may be served with different color if necessary. When false, the ad will be served with the specified colors or a neutral color. The default value is true. Must be true if main_color and accent_color are not set. accent_color (str): The accent color of the ad in hexadecimal, e.g. #ffffff for white. If one of main_color and accent_color is set, the other is required as well. main_color (str): The main color of the ad in hexadecimal, e.g. #ffffff for white. If one of main_color and accent_color is set, the other is required as well. call_to_action_text (str): The call-to-action text for the ad. logo_image (str): The MediaFile resource name of the logo image used in the ad. square_logo_image (str): The MediaFile resource name of the square logo image used in the ad. marketing_image (str): The MediaFile resource name of the marketing image used in the ad. square_marketing_image (str): The MediaFile resource name of the square marketing image used in the ad. format_setting (google.ads.googleads.v8.enums.types.DisplayAdFormatSettingEnum.DisplayAdFormatSetting): Specifies which format the ad will be served in. Default is ALL_FORMATS. price_prefix (str): Prefix before price. E.g. 'as low as'. promo_text (str): Promotion text used for dynamic formats of responsive ads. For example 'Free two-day shipping'. """ short_headline = proto.Field( proto.STRING, number=16, optional=True, ) long_headline = proto.Field( proto.STRING, number=17, optional=True, ) description = proto.Field( proto.STRING, number=18, optional=True, ) business_name = proto.Field( proto.STRING, number=19, optional=True, ) allow_flexible_color = proto.Field( proto.BOOL, number=20, optional=True, ) accent_color = proto.Field( proto.STRING, number=21, optional=True, ) main_color = proto.Field( proto.STRING, number=22, optional=True, ) call_to_action_text = proto.Field( proto.STRING, number=23, optional=True, ) logo_image = proto.Field( proto.STRING, number=24, optional=True, ) square_logo_image = proto.Field( proto.STRING, number=25, optional=True, ) marketing_image = proto.Field( proto.STRING, number=26, optional=True, ) square_marketing_image = proto.Field( proto.STRING, number=27, optional=True, ) format_setting = proto.Field( proto.ENUM, number=13, enum=display_ad_format_setting.DisplayAdFormatSettingEnum.DisplayAdFormatSetting, ) price_prefix = proto.Field( proto.STRING, number=28, optional=True, ) promo_text = proto.Field( proto.STRING, number=29, optional=True, ) class AppAdInfo(proto.Message): r"""An app ad. Attributes: mandatory_ad_text (google.ads.googleads.v8.common.types.AdTextAsset): Mandatory ad text. headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for headlines. When the ad serves the headlines will be selected from this list. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for descriptions. When the ad serves the descriptions will be selected from this list. images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): List of image assets that may be displayed with the ad. youtube_videos (Sequence[google.ads.googleads.v8.common.types.AdVideoAsset]): List of YouTube video assets that may be displayed with the ad. html5_media_bundles (Sequence[google.ads.googleads.v8.common.types.AdMediaBundleAsset]): List of media bundle assets that may be used with the ad. """ mandatory_ad_text = proto.Field( proto.MESSAGE, number=1, message=ad_asset.AdTextAsset, ) headlines = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=3, message=ad_asset.AdTextAsset, ) images = proto.RepeatedField( proto.MESSAGE, number=4, message=ad_asset.AdImageAsset, ) youtube_videos = proto.RepeatedField( proto.MESSAGE, number=5, message=ad_asset.AdVideoAsset, ) html5_media_bundles = proto.RepeatedField( proto.MESSAGE, number=6, message=ad_asset.AdMediaBundleAsset, ) class AppEngagementAdInfo(proto.Message): r"""App engagement ads allow you to write text encouraging a specific action in the app, like checking in, making a purchase, or booking a flight. They allow you to send users to a specific part of your app where they can find what they're looking for easier and faster. Attributes: headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for headlines. When the ad serves the headlines will be selected from this list. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for descriptions. When the ad serves the descriptions will be selected from this list. images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): List of image assets that may be displayed with the ad. videos (Sequence[google.ads.googleads.v8.common.types.AdVideoAsset]): List of video assets that may be displayed with the ad. """ headlines = proto.RepeatedField( proto.MESSAGE, number=1, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdTextAsset, ) images = proto.RepeatedField( proto.MESSAGE, number=3, message=ad_asset.AdImageAsset, ) videos = proto.RepeatedField( proto.MESSAGE, number=4, message=ad_asset.AdVideoAsset, ) class LegacyAppInstallAdInfo(proto.Message): r"""A legacy app install ad that only can be used by a few select customers. Attributes: app_id (str): The id of the mobile app. app_store (google.ads.googleads.v8.enums.types.LegacyAppInstallAdAppStoreEnum.LegacyAppInstallAdAppStore): The app store the mobile app is available in. headline (str): The headline of the ad. description1 (str): The first description line of the ad. description2 (str): The second description line of the ad. """ app_id = proto.Field( proto.STRING, number=6, optional=True, ) app_store = proto.Field( proto.ENUM, number=2, enum=legacy_app_install_ad_app_store.LegacyAppInstallAdAppStoreEnum.LegacyAppInstallAdAppStore, ) headline = proto.Field( proto.STRING, number=7, optional=True, ) description1 = proto.Field( proto.STRING, number=8, optional=True, ) description2 = proto.Field( proto.STRING, number=9, optional=True, ) class ResponsiveDisplayAdInfo(proto.Message): r"""A responsive display ad. Attributes: marketing_images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): Marketing images to be used in the ad. Valid image types are GIF, JPEG, and PNG. The minimum size is 600x314 and the aspect ratio must be 1.91:1 (+-1%). At least one marketing_image is required. Combined with square_marketing_images the maximum is 15. square_marketing_images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): Square marketing images to be used in the ad. Valid image types are GIF, JPEG, and PNG. The minimum size is 300x300 and the aspect ratio must be 1:1 (+-1%). At least one square marketing_image is required. Combined with marketing_images the maximum is 15. logo_images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): Logo images to be used in the ad. Valid image types are GIF, JPEG, and PNG. The minimum size is 512x128 and the aspect ratio must be 4:1 (+-1%). Combined with square_logo_images the maximum is 5. square_logo_images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): Square logo images to be used in the ad. Valid image types are GIF, JPEG, and PNG. The minimum size is 128x128 and the aspect ratio must be 1:1 (+-1%). Combined with square_logo_images the maximum is 5. headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): Short format headlines for the ad. The maximum length is 30 characters. At least 1 and max 5 headlines can be specified. long_headline (google.ads.googleads.v8.common.types.AdTextAsset): A required long format headline. The maximum length is 90 characters. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): Descriptive texts for the ad. The maximum length is 90 characters. At least 1 and max 5 headlines can be specified. youtube_videos (Sequence[google.ads.googleads.v8.common.types.AdVideoAsset]): Optional YouTube videos for the ad. A maximum of 5 videos can be specified. business_name (str): The advertiser/brand name. Maximum display width is 25. main_color (str): The main color of the ad in hexadecimal, e.g. #ffffff for white. If one of main_color and accent_color is set, the other is required as well. accent_color (str): The accent color of the ad in hexadecimal, e.g. #ffffff for white. If one of main_color and accent_color is set, the other is required as well. allow_flexible_color (bool): Advertiser's consent to allow flexible color. When true, the ad may be served with different color if necessary. When false, the ad will be served with the specified colors or a neutral color. The default value is true. Must be true if main_color and accent_color are not set. call_to_action_text (str): The call-to-action text for the ad. Maximum display width is 30. price_prefix (str): Prefix before price. E.g. 'as low as'. promo_text (str): Promotion text used for dynamic formats of responsive ads. For example 'Free two-day shipping'. format_setting (google.ads.googleads.v8.enums.types.DisplayAdFormatSettingEnum.DisplayAdFormatSetting): Specifies which format the ad will be served in. Default is ALL_FORMATS. control_spec (google.ads.googleads.v8.common.types.ResponsiveDisplayAdControlSpec): Specification for various creative controls. """ marketing_images = proto.RepeatedField( proto.MESSAGE, number=1, message=ad_asset.AdImageAsset, ) square_marketing_images = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdImageAsset, ) logo_images = proto.RepeatedField( proto.MESSAGE, number=3, message=ad_asset.AdImageAsset, ) square_logo_images = proto.RepeatedField( proto.MESSAGE, number=4, message=ad_asset.AdImageAsset, ) headlines = proto.RepeatedField( proto.MESSAGE, number=5, message=ad_asset.AdTextAsset, ) long_headline = proto.Field( proto.MESSAGE, number=6, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=7, message=ad_asset.AdTextAsset, ) youtube_videos = proto.RepeatedField( proto.MESSAGE, number=8, message=ad_asset.AdVideoAsset, ) business_name = proto.Field( proto.STRING, number=17, optional=True, ) main_color = proto.Field( proto.STRING, number=18, optional=True, ) accent_color = proto.Field( proto.STRING, number=19, optional=True, ) allow_flexible_color = proto.Field( proto.BOOL, number=20, optional=True, ) call_to_action_text = proto.Field( proto.STRING, number=21, optional=True, ) price_prefix = proto.Field( proto.STRING, number=22, optional=True, ) promo_text = proto.Field( proto.STRING, number=23, optional=True, ) format_setting = proto.Field( proto.ENUM, number=16, enum=display_ad_format_setting.DisplayAdFormatSettingEnum.DisplayAdFormatSetting, ) control_spec = proto.Field( proto.MESSAGE, number=24, message='ResponsiveDisplayAdControlSpec', ) class LocalAdInfo(proto.Message): r"""A local ad. Attributes: headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for headlines. When the ad serves the headlines will be selected from this list. At least 1 and at most 5 headlines must be specified. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for descriptions. When the ad serves the descriptions will be selected from this list. At least 1 and at most 5 descriptions must be specified. call_to_actions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for call-to-actions. When the ad serves the call-to-actions will be selected from this list. Call-to-actions are optional and at most 5 can be specified. marketing_images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): List of marketing image assets that may be displayed with the ad. The images must be 314x600 pixels or 320x320 pixels. At least 1 and at most 20 image assets must be specified. logo_images (Sequence[google.ads.googleads.v8.common.types.AdImageAsset]): List of logo image assets that may be displayed with the ad. The images must be 128x128 pixels and not larger than 120KB. At least 1 and at most 5 image assets must be specified. videos (Sequence[google.ads.googleads.v8.common.types.AdVideoAsset]): List of YouTube video assets that may be displayed with the ad. Videos are optional and at most 20 can be specified. path1 (str): First part of optional text that may appear appended to the url displayed in the ad. path2 (str): Second part of optional text that may appear appended to the url displayed in the ad. This field can only be set when path1 is also set. """ headlines = proto.RepeatedField( proto.MESSAGE, number=1, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdTextAsset, ) call_to_actions = proto.RepeatedField( proto.MESSAGE, number=3, message=ad_asset.AdTextAsset, ) marketing_images = proto.RepeatedField( proto.MESSAGE, number=4, message=ad_asset.AdImageAsset, ) logo_images = proto.RepeatedField( proto.MESSAGE, number=5, message=ad_asset.AdImageAsset, ) videos = proto.RepeatedField( proto.MESSAGE, number=6, message=ad_asset.AdVideoAsset, ) path1 = proto.Field( proto.STRING, number=9, optional=True, ) path2 = proto.Field( proto.STRING, number=10, optional=True, ) class DisplayUploadAdInfo(proto.Message): r"""A generic type of display ad. The exact ad format is controlled by the display_upload_product_type field, which determines what kinds of data need to be included with the ad. Attributes: display_upload_product_type (google.ads.googleads.v8.enums.types.DisplayUploadProductTypeEnum.DisplayUploadProductType): The product type of this ad. See comments on the enum for details. media_bundle (google.ads.googleads.v8.common.types.AdMediaBundleAsset): A media bundle asset to be used in the ad. For information about the media bundle for HTML5_UPLOAD_AD see https://support.google.com/google-ads/answer/1722096 Media bundles that are part of dynamic product types use a special format that needs to be created through the Google Web Designer. See https://support.google.com/webdesigner/answer/7543898 for more information. """ display_upload_product_type = proto.Field( proto.ENUM, number=1, enum=gage_display_upload_product_type.DisplayUploadProductTypeEnum.DisplayUploadProductType, ) media_bundle = proto.Field( proto.MESSAGE, number=2, oneof='media_asset', message=ad_asset.AdMediaBundleAsset, ) class ResponsiveDisplayAdControlSpec(proto.Message): r"""Specification for various creative controls for a responsive display ad. Attributes: enable_asset_enhancements (bool): Whether the advertiser has opted into the asset enhancements feature. enable_autogen_video (bool): Whether the advertiser has opted into auto- en video feature. """ enable_asset_enhancements = proto.Field( proto.BOOL, number=1, ) enable_autogen_video = proto.Field( proto.BOOL, number=2, ) class SmartCampaignAdInfo(proto.Message): r"""A Smart campaign ad. Attributes: headlines (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for headlines. When the ad serves the headlines will be selected from this list. 3 headlines must be specified. descriptions (Sequence[google.ads.googleads.v8.common.types.AdTextAsset]): List of text assets for descriptions. When the ad serves the descriptions will be selected from this list. 2 descriptions must be specified. """ headlines = proto.RepeatedField( proto.MESSAGE, number=1, message=ad_asset.AdTextAsset, ) descriptions = proto.RepeatedField( proto.MESSAGE, number=2, message=ad_asset.AdTextAsset, ) class CallAdInfo(proto.Message): r"""A call ad. Attributes: country_code (str): The country code in the ad. phone_number (str): The phone number in the ad. business_name (str): The business name in the ad. headline1 (str): First headline in the ad. headline2 (str): Second headline in the ad. description1 (str): The first line of the ad's description. description2 (str): The second line of the ad's description. call_tracked (bool): Whether to enable call tracking for the creative. Enabling call tracking also enables call conversions. disable_call_conversion (bool): Whether to disable call conversion for the creative. If set to ``true``, disables call conversions even when ``call_tracked`` is ``true``. If ``call_tracked`` is ``false``, this field is ignored. phone_number_verification_url (str): The URL to be used for phone number verification. conversion_action (str): The conversion action to attribute a call conversion to. If not set a default conversion action is used. This field only has effect if call_tracked is set to true. Otherwise this field is ignored. conversion_reporting_state (google.ads.googleads.v8.enums.types.CallConversionReportingStateEnum.CallConversionReportingState): The call conversion behavior of this call ad. It can use its own call conversion setting, inherit the account level setting, or be disabled. path1 (str): First part of text that may appear appended to the url displayed to in the ad. Optional. path2 (str): Second part of text that may appear appended to the url displayed to in the ad. This field can only be set when path1 is set. Optional. """ country_code = proto.Field( proto.STRING, number=1, ) phone_number = proto.Field( proto.STRING, number=2, ) business_name = proto.Field( proto.STRING, number=3, ) headline1 = proto.Field( proto.STRING, number=11, ) headline2 = proto.Field( proto.STRING, number=12, ) description1 = proto.Field( proto.STRING, number=4, ) description2 = proto.Field( proto.STRING, number=5, ) call_tracked = proto.Field( proto.BOOL, number=6, ) disable_call_conversion = proto.Field( proto.BOOL, number=7, ) phone_number_verification_url = proto.Field( proto.STRING, number=8, ) conversion_action = proto.Field( proto.STRING, number=9, ) conversion_reporting_state = proto.Field( proto.ENUM, number=10, enum=call_conversion_reporting_state.CallConversionReportingStateEnum.CallConversionReportingState, ) path1 = proto.Field( proto.STRING, number=13, ) path2 = proto.Field( proto.STRING, number=14, ) __all__ = tuple(sorted(__protobuf__.manifest))
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 25455, 4475, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 4104, 221, 327, 730, 26, 3686, 199, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 2330, 14, 1313, 492, 1503, 63, 6562, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 1240, 63, 15083, 63, 28071, 63, 929, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 2929, 63, 350, 63, 908, 63, 6031, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 2929, 63, 5064, 63, 2558, 63, 466, 465, 486, 474, 63, 2918, 63, 5064, 63, 2558, 63, 466, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 12139, 63, 571, 63, 3174, 63, 350, 63, 571, 63, 1617, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 6660, 63, 466, 465, 486, 474, 63, 7626, 63, 466, 421, 199, 363, 7204, 363, 275, 4104, 14, 578, 8, 272, 2559, 534, 3098, 14, 9402, 14, 29882, 14, 86, 24, 14, 2330, 297, 272, 21985, 534, 3098, 14, 9402, 14, 29882, 14, 86, 24, 297, 272, 7712, 3126, 267, 283, 1872, 2767, 2354, 297, 267, 283, 27136, 1872, 2767, 2354, 297, 267, 283, 27136, 14451, 5278, 2767, 2354, 297, 267, 283, 40, 1583, 76, 2767, 2354, 297, 267, 283, 2662, 411, 4073, 29111, 2767, 2354, 297, 267, 283, 2662, 411, 4073, 5884, 2767, 2354, 297, 267, 283, 2662, 411, 4073, 25834, 26138, 2767, 2354, 297, 267, 283, 39, 1198, 2767, 2354, 297, 267, 283, 39, 1198, 52, 4489, 332, 297, 267, 283, 7687, 2176, 1378, 3310, 297, 267, 283, 5884, 3491, 297, 267, 283, 5884, 9166, 297, 267, 283, 3491, 2767, 2354, 297, 267, 283, 9166, 34, 1220, 281, 607, 3296, 2767, 2354, 297, 267, 283, 9166, 6932, 7738, 80, 461, 607, 3296, 2767, 2354, 297, 267, 283, 9166, 549, 2768, 607, 3296, 2767, 2354, 297, 267, 283, 9166, 2204, 1745, 2767, 2354, 297, 267, 283, 9166, 549, 2768, 2825, 6913, 2767, 2354, 297, 267, 283, 9166, 2767, 2354, 297, 267, 283, 9166, 1322, 678, 3398, 2767, 2354, 297, 267, 283, 1322, 678, 3398, 5278, 2767, 2354, 297, 267, 283, 22628, 1322, 678, 3398, 7687, 2767, 2354, 297, 267, 283, 2640, 2767, 2354, 297, 267, 283, 2640, 16197, 4103, 2767, 2354, 297, 267, 283, 22628, 2640, 8154, 2767, 2354, 297, 267, 283, 1322, 678, 3398, 7687, 2767, 2354, 297, 267, 283, 5339, 2767, 2354, 297, 267, 283, 7687, 10301, 2767, 2354, 297, 267, 283, 1322, 678, 3398, 7687, 2767, 3717, 5307, 297, 267, 283, 29111, 3630, 11721, 2767, 2354, 297, 267, 283, 2176, 2767, 2354, 297, 272, 1660, 199, 9, 421, 199, 533, 4516, 2767, 2354, 8, 2625, 14, 2209, 304, 272, 519, 624, 33, 1318, 1503, 14, 272, 9382, 26, 267, 21250, 334, 495, 304, 288, 710, 21250, 402, 314, 1503, 14, 267, 1369, 17, 334, 495, 304, 288, 710, 1642, 1004, 402, 314, 1503, 1159, 1369, 14, 267, 1369, 18, 334, 495, 304, 288, 710, 3499, 1004, 402, 314, 1503, 1159, 1369, 14, 272, 408, 339, 21250, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 20, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 17, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 21, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 18, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 22, 12, 267, 2716, 29, 549, 12, 272, 776, 421, 199, 533, 7910, 7028, 1872, 2767, 2354, 8, 2625, 14, 2209, 304, 272, 519, 624, 2493, 11507, 1318, 1503, 14, 272, 9382, 26, 267, 21250, 63, 2064, 17, 334, 495, 304, 288, 710, 1642, 1777, 402, 314, 1503, 1159, 21250, 14, 267, 21250, 63, 2064, 18, 334, 495, 304, 288, 710, 3499, 1777, 402, 314, 1503, 1159, 21250, 14, 267, 21250, 63, 2064, 19, 334, 495, 304, 288, 710, 10919, 1777, 402, 314, 1503, 1159, 21250, 14, 267, 1369, 334, 495, 304, 288, 710, 1369, 402, 314, 1503, 14, 267, 1369, 18, 334, 495, 304, 288, 710, 3499, 1369, 402, 314, 1503, 14, 267, 931, 17, 334, 495, 304, 288, 710, 1318, 626, 883, 7468, 3180, 2441, 314, 1503, 1159, 288, 9080, 2851, 14, 267, 931, 18, 334, 495, 304, 288, 10961, 1318, 626, 883, 7468, 3180, 2441, 314, 288, 1503, 1159, 9080, 2851, 14, 272, 408, 339, 21250, 63, 2064, 17, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 24, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 21250, 63, 2064, 18, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 25, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 21250, 63, 2064, 19, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 709, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 845, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 18, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 713, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 931, 17, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 25455, 4475, 20376, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 4104, 221, 327, 730, 26, 3686, 199, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 2330, 14, 1313, 492, 1503, 63, 6562, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 1240, 63, 15083, 63, 28071, 63, 929, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 2929, 63, 350, 63, 908, 63, 6031, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 2929, 63, 5064, 63, 2558, 63, 466, 465, 486, 474, 63, 2918, 63, 5064, 63, 2558, 63, 466, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 12139, 63, 571, 63, 3174, 63, 350, 63, 571, 63, 1617, 199, 504, 6233, 14, 9402, 14, 29882, 14, 86, 24, 14, 19921, 14, 1313, 492, 6660, 63, 466, 465, 486, 474, 63, 7626, 63, 466, 421, 199, 363, 7204, 363, 275, 4104, 14, 578, 8, 272, 2559, 534, 3098, 14, 9402, 14, 29882, 14, 86, 24, 14, 2330, 297, 272, 21985, 534, 3098, 14, 9402, 14, 29882, 14, 86, 24, 297, 272, 7712, 3126, 267, 283, 1872, 2767, 2354, 297, 267, 283, 27136, 1872, 2767, 2354, 297, 267, 283, 27136, 14451, 5278, 2767, 2354, 297, 267, 283, 40, 1583, 76, 2767, 2354, 297, 267, 283, 2662, 411, 4073, 29111, 2767, 2354, 297, 267, 283, 2662, 411, 4073, 5884, 2767, 2354, 297, 267, 283, 2662, 411, 4073, 25834, 26138, 2767, 2354, 297, 267, 283, 39, 1198, 2767, 2354, 297, 267, 283, 39, 1198, 52, 4489, 332, 297, 267, 283, 7687, 2176, 1378, 3310, 297, 267, 283, 5884, 3491, 297, 267, 283, 5884, 9166, 297, 267, 283, 3491, 2767, 2354, 297, 267, 283, 9166, 34, 1220, 281, 607, 3296, 2767, 2354, 297, 267, 283, 9166, 6932, 7738, 80, 461, 607, 3296, 2767, 2354, 297, 267, 283, 9166, 549, 2768, 607, 3296, 2767, 2354, 297, 267, 283, 9166, 2204, 1745, 2767, 2354, 297, 267, 283, 9166, 549, 2768, 2825, 6913, 2767, 2354, 297, 267, 283, 9166, 2767, 2354, 297, 267, 283, 9166, 1322, 678, 3398, 2767, 2354, 297, 267, 283, 1322, 678, 3398, 5278, 2767, 2354, 297, 267, 283, 22628, 1322, 678, 3398, 7687, 2767, 2354, 297, 267, 283, 2640, 2767, 2354, 297, 267, 283, 2640, 16197, 4103, 2767, 2354, 297, 267, 283, 22628, 2640, 8154, 2767, 2354, 297, 267, 283, 1322, 678, 3398, 7687, 2767, 2354, 297, 267, 283, 5339, 2767, 2354, 297, 267, 283, 7687, 10301, 2767, 2354, 297, 267, 283, 1322, 678, 3398, 7687, 2767, 3717, 5307, 297, 267, 283, 29111, 3630, 11721, 2767, 2354, 297, 267, 283, 2176, 2767, 2354, 297, 272, 1660, 199, 9, 421, 199, 533, 4516, 2767, 2354, 8, 2625, 14, 2209, 304, 272, 519, 624, 33, 1318, 1503, 14, 272, 9382, 26, 267, 21250, 334, 495, 304, 288, 710, 21250, 402, 314, 1503, 14, 267, 1369, 17, 334, 495, 304, 288, 710, 1642, 1004, 402, 314, 1503, 1159, 1369, 14, 267, 1369, 18, 334, 495, 304, 288, 710, 3499, 1004, 402, 314, 1503, 1159, 1369, 14, 272, 408, 339, 21250, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 20, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 17, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 21, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 18, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 22, 12, 267, 2716, 29, 549, 12, 272, 776, 421, 199, 533, 7910, 7028, 1872, 2767, 2354, 8, 2625, 14, 2209, 304, 272, 519, 624, 2493, 11507, 1318, 1503, 14, 272, 9382, 26, 267, 21250, 63, 2064, 17, 334, 495, 304, 288, 710, 1642, 1777, 402, 314, 1503, 1159, 21250, 14, 267, 21250, 63, 2064, 18, 334, 495, 304, 288, 710, 3499, 1777, 402, 314, 1503, 1159, 21250, 14, 267, 21250, 63, 2064, 19, 334, 495, 304, 288, 710, 10919, 1777, 402, 314, 1503, 1159, 21250, 14, 267, 1369, 334, 495, 304, 288, 710, 1369, 402, 314, 1503, 14, 267, 1369, 18, 334, 495, 304, 288, 710, 3499, 1369, 402, 314, 1503, 14, 267, 931, 17, 334, 495, 304, 288, 710, 1318, 626, 883, 7468, 3180, 2441, 314, 1503, 1159, 288, 9080, 2851, 14, 267, 931, 18, 334, 495, 304, 288, 10961, 1318, 626, 883, 7468, 3180, 2441, 314, 288, 1503, 1159, 9080, 2851, 14, 272, 408, 339, 21250, 63, 2064, 17, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 24, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 21250, 63, 2064, 18, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 25, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 21250, 63, 2064, 19, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 709, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 845, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 1369, 18, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 12, 267, 1329, 29, 713, 12, 267, 2716, 29, 549, 12, 272, 776, 272, 931, 17, 275, 4104, 14, 792, 8, 267, 4104, 14, 5353, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mapzen/tilequeue
tilequeue/wof.py
1
46004
from __future__ import absolute_import from collections import namedtuple from contextlib import closing from cStringIO import StringIO from datetime import datetime from edtf import parse_edtf from operator import attrgetter from psycopg2.extras import register_hstore from shapely import geos from tilequeue.tile import coord_marshall_int from tilequeue.tile import coord_unmarshall_int from tilequeue.tile import mercator_point_to_coord from tilequeue.tile import reproject_lnglat_to_mercator import csv import json import os.path import psycopg2 import Queue import requests import shapely.geometry import shapely.ops import shapely.wkb import threading DATABASE_SRID = 3857 def generate_csv_lines(requests_result): for line in requests_result.iter_lines(): if line: yield line neighbourhood_placetypes_to_int = dict( neighbourhood=1, microhood=2, macrohood=3, borough=4, ) neighbourhood_int_to_placetypes = { 1: 'neighbourhood', 2: 'microhood', 3: 'macrohood', 4: 'borough', } NeighbourhoodMeta = namedtuple( 'NeighbourhoodMeta', 'wof_id placetype name hash label_position') Neighbourhood = namedtuple( 'Neighbourhood', 'wof_id placetype name hash label_position geometry n_photos area ' 'min_zoom max_zoom is_landuse_aoi inception cessation l10n_names') def parse_neighbourhood_meta_csv(csv_line_generator, placetype): reader = csv.reader(csv_line_generator) it = iter(reader) header = it.next() lbl_lat_idx = header.index('lbl_latitude') lbl_lng_idx = header.index('lbl_longitude') name_idx = header.index('name') wof_id_idx = header.index('id') hash_idx = header.index('file_hash') superseded_by_idx = header.index('superseded_by') min_row_length = (max( lbl_lat_idx, lbl_lng_idx, name_idx, wof_id_idx, hash_idx, superseded_by_idx) + 1) for row in it: if len(row) < min_row_length: continue superseded_by = row[superseded_by_idx] if superseded_by: continue wof_id_str = row[wof_id_idx] if not wof_id_str: continue try: wof_id = int(wof_id_str) except ValueError: continue name = row[name_idx] if not name: continue lat_str = row[lbl_lat_idx] lng_str = row[lbl_lng_idx] try: lat = float(lat_str) lng = float(lng_str) except ValueError: continue file_hash = row[hash_idx] label_x, label_y = reproject_lnglat_to_mercator(lng, lat) label_position = shapely.geometry.Point(label_x, label_y) neighbourhood_meta = NeighbourhoodMeta( wof_id, placetype, name, file_hash, label_position) yield neighbourhood_meta def _make_requests_session_with_retries(max_retries): from requests.adapters import HTTPAdapter from requests.packages.urllib3.util import Retry s = requests.Session() a = HTTPAdapter( max_retries=Retry( total=max_retries, status_forcelist=[ # this is a list of statuses to consider to be # an error and retry. 429, # Too many requests (i.e: back off) 500, # Generic internal server error 502, # Bad Gateway - i.e: upstream failure 503, # Unavailable, temporarily 504, # Gateway timeout 522 # Origin connection timed out ], backoff_factor=1.0 # back off for 0s, 1s, 3s, 7s, etc... after # each successive failure. (factor*(2^N-1)) )) # use retry for both HTTP and HTTPS connections. s.mount('http://', a) s.mount('https://', a) return s def fetch_wof_url_meta_neighbourhoods(url, placetype, max_retries): s = _make_requests_session_with_retries(max_retries) r = s.get(url, stream=True) assert r.status_code == 200, 'Failure requesting: %s' % url csv_line_generator = generate_csv_lines(r) return parse_neighbourhood_meta_csv(csv_line_generator, placetype) class NeighbourhoodFailure(object): def __init__(self, wof_id, reason, message, halt=False, skipped=False, funky=False, superseded=False): # halt is a signal that threads should stop fetching. This # would happen during a network IO error or when we get an # unexpected http response when fetching raw json files. In # some scenarios this could be recoverable, but because that # isn't always the case we assume that we should stop further # requests for more raw json files, and just process what we # have so far. # skipped means that we won't log this failure, ie there was # an earlier "halt" error and processing of further records # has stopped. # funky is a signal downstream that this is a "soft" or # expected failure, in the sense that it only means that we # should skip the record, but we didn't actually detect any # errors with the processing # superseded is set when the json has a value for # wof:superseded. This would indicate a data inconsistency # because the meta csv file didn't have it set if we're trying # to fetch the raw json in the first place. But this is meant # to catch this scenario. self.wof_id = wof_id self.reason = reason self.message = message self.halt = halt self.skipped = skipped self.funky = funky self.superseded = superseded # given a string, parse it as EDTF while allowing a single 'u' or None to mean # completely unknown, and return the EDTF object. def _normalize_edtf(s): if s and s != 'u': try: return parse_edtf(s) except Exception: pass # when all else fails, return the "most unknown" EDTF. return parse_edtf('uuuu') def create_neighbourhood_from_json(json_data, neighbourhood_meta): def failure(reason): return NeighbourhoodFailure( neighbourhood_meta.wof_id, reason, json.dumps(json_data)) if not isinstance(json_data, dict): return failure('Unexpected json') props = json_data.get('properties') if props is None or not isinstance(props, dict): return failure('Missing properties') superseded_by = props.get('wof:superseded_by') # these often show up as empty lists, so we do a truthy test # instead of expicitly checking for None if superseded_by: return NeighbourhoodFailure( neighbourhood_meta.wof_id, 'superseded_by: %s' % superseded_by, json.dumps(json_data), superseded=True) geometry = json_data.get('geometry') if geometry is None: return failure('Missing geometry') try: shape_lnglat = shapely.geometry.shape(geometry) except Exception: return failure('Unexpected geometry') shape_mercator = shapely.ops.transform( reproject_lnglat_to_mercator, shape_lnglat) # ignore any features that are marked as funky is_funky = props.get('mz:is_funky') if is_funky is not None: try: is_funky = int(is_funky) except ValueError: return failure('Unexpected mz:is_funky value %s' % is_funky) if is_funky != 0: return NeighbourhoodFailure( neighbourhood_meta.wof_id, 'mz:is_funky value is not 0: %s' % is_funky, json.dumps(json_data), funky=True) wof_id = props.get('wof:id') if wof_id is None: return failure('Missing wof:id') try: wof_id = int(wof_id) except ValueError: return failure('wof_id is not an int: %s' % wof_id) name = props.get('wof:name') if name is None: return failure('Missing name') n_photos = props.get('misc:photo_sum') if n_photos is not None: try: n_photos = int(n_photos) except ValueError: return failure('misc:photo_sum is not an int: %s' % n_photos) label_lat = props.get('lbl:latitude') label_lng = props.get('lbl:longitude') if label_lat is None or label_lng is None: # first, try to fall back to geom:* when lbl:* is missing. we'd prefer # to have lbl:*, but it's better to have _something_ than nothing. label_lat = props.get('geom:latitude') label_lng = props.get('geom:longitude') if label_lat is None or label_lng is None: return failure('Missing lbl:latitude or lbl:longitude and ' + 'geom:latitude or geom:longitude') try: label_lat = float(label_lat) label_lng = float(label_lng) except ValueError: return failure('lbl:latitude or lbl:longitude not float') label_merc_x, label_merc_y = reproject_lnglat_to_mercator( label_lng, label_lat) label_position = shapely.geometry.Point(label_merc_x, label_merc_y) placetype = props.get('wof:placetype') if placetype is None: return failure('Missing wof:placetype') default_min_zoom = 15 default_max_zoom = 16 min_zoom = props.get('mz:min_zoom') if min_zoom is None: min_zoom = default_min_zoom else: try: min_zoom = float(min_zoom) except ValueError: return failure('mz:min_zoom not float: %s' % min_zoom) max_zoom = props.get('mz:max_zoom') if max_zoom is None: max_zoom = default_max_zoom else: try: max_zoom = float(max_zoom) except ValueError: return failure('mz:max_zoom not float: %s' % max_zoom) is_landuse_aoi = props.get('mz:is_landuse_aoi') if is_landuse_aoi is not None: try: is_landuse_aoi = int(is_landuse_aoi) except ValueError: return failure('is_landuse_aoi not int: %s' % is_landuse_aoi) is_landuse_aoi = is_landuse_aoi != 0 if shape_mercator.type in ('Polygon', 'MultiPolygon'): area = int(shape_mercator.area) else: area = None # for the purposes of display, we only care about the times when something # should first start to be shown, and the time when it should stop # showing. edtf_inception = _normalize_edtf(props.get('edtf:inception')) edtf_cessation = _normalize_edtf(props.get('edtf:cessation')) edtf_deprecated = _normalize_edtf(props.get('edtf:deprecated')) # check that the dates are valid first to return back a better error inception_earliest = edtf_inception.lower_fuzzy() cessation_latest = edtf_cessation.upper_fuzzy() deprecated_latest = edtf_deprecated.upper_fuzzy() if inception_earliest is None: return failure('invalid edtf:inception: %s' % props.get('edtf:inception')) if cessation_latest is None: return failure('invalid edtf:cessation: %s' % props.get('edtf:cessation')) if deprecated_latest is None: return failure('invalid edtf:deprecated: %s' % props.get('edtf:deprecated')) # the 'edtf:inception' property gives us approximately the former and we # take the earliest date it could mean. the 'edtf:cessation' and # 'edtf:deprecated' would both stop the item showing, so we take the # earliest of each's latest possible date. inception = inception_earliest cessation = min(cessation_latest, deprecated_latest) # grab any names in other languages lang_suffix_size = len('_preferred') l10n_names = {} for k, v in props.iteritems(): if not v: continue if not k.startswith('name:') or not k.endswith('_preferred'): continue if isinstance(v, list): v = v[0] lang = k[:-lang_suffix_size] l10n_names[lang] = v if not l10n_names: l10n_names = None neighbourhood = Neighbourhood( wof_id, placetype, name, neighbourhood_meta.hash, label_position, shape_mercator, n_photos, area, min_zoom, max_zoom, is_landuse_aoi, inception, cessation, l10n_names) return neighbourhood def fetch_url_raw_neighbourhood(url, neighbourhood_meta, max_retries): try: s = _make_requests_session_with_retries(max_retries) r = s.get(url) except Exception, e: # if there is an IO error when fetching the url itself, we'll # want to halt too return NeighbourhoodFailure( neighbourhood_meta.wof_id, 'IO Error fetching %s' % url, str(e), halt=True) if r.status_code != 200: # once we don't get a 200, signal that we should stop all # remaining processing return NeighbourhoodFailure( neighbourhood_meta.wof_id, 'Invalid response %d for %s' % (r.status_code, url), r.text, halt=True) try: doc = r.json() except Exception, e: return NeighbourhoodFailure( neighbourhood_meta.wof_id, 'Response is not json for %s' % url, r.text) try: neighbourhood = create_neighbourhood_from_json(doc, neighbourhood_meta) except Exception, e: return NeighbourhoodFailure( neighbourhood_meta.wof_id, 'Unexpected exception parsing json', json.dumps(doc)) return neighbourhood def fetch_fs_raw_neighbourhood(path, neighbourhood_meta): with open(path) as fp: json_data = json.load(fp) neighbourhood = create_neighbourhood_from_json(json_data, neighbourhood_meta) return neighbourhood def generate_wof_url(url_prefix, wof_id): wof_id_str = str(wof_id) grouped = [] grouping = [] for c in wof_id_str: grouping.append(c) if len(grouping) == 3: grouped.append(grouping) grouping = [] if grouping: grouped.append(grouping) grouped_part = '/'.join([''.join(part) for part in grouped]) wof_url = '%s/%s/%s.geojson' % (url_prefix, grouped_part, wof_id_str) return wof_url def make_fetch_raw_url_fn(data_url_prefix, max_retries): def fn(neighbourhood_meta): wof_url = generate_wof_url( data_url_prefix, neighbourhood_meta.wof_id) neighbourhood = fetch_url_raw_neighbourhood(wof_url, neighbourhood_meta, max_retries) return neighbourhood return fn def make_fetch_raw_filesystem_fn(data_path): def fn(neighbourhood_meta): # this will work for OS's with / separators wof_path = generate_wof_url( data_path, neighbourhood_meta.wof_id) neighbourhood = fetch_fs_raw_neighbourhood(wof_path, neighbourhood_meta) return neighbourhood return fn def threaded_fetch(neighbourhood_metas, n_threads, fetch_raw_fn): queue_size = n_threads * 10 neighbourhood_input_queue = Queue.Queue(queue_size) neighbourhood_output_queue = Queue.Queue(len(neighbourhood_metas)) stop = threading.Event() def _fetch_raw_neighbourhood(): while True: neighbourhood_meta = neighbourhood_input_queue.get() if neighbourhood_meta is None: break if stop.is_set(): # assume all remaining neighbourhoods are failures # these will get skipped neighbourhood_output_queue.put(NeighbourhoodFailure( neighbourhood_meta.wof_id, 'Skipping remaining neighbourhoods', 'Skipping remaining neighbourhoods', skipped=True)) continue neighbourhood = fetch_raw_fn(neighbourhood_meta) if isinstance(neighbourhood, NeighbourhoodFailure): failure = neighbourhood # if this is the type of error that should stop all # processing, notify all other threads if failure.halt: stop.set() neighbourhood_output_queue.put(neighbourhood) fetch_threads = [] for i in xrange(n_threads): fetch_thread = threading.Thread(target=_fetch_raw_neighbourhood) fetch_thread.start() fetch_threads.append(fetch_thread) for neighbourhood_meta in neighbourhood_metas: neighbourhood_input_queue.put(neighbourhood_meta) for fetch_thread in fetch_threads: neighbourhood_input_queue.put(None) neighbourhoods = [] failures = [] for i in xrange(len(neighbourhood_metas)): neighbourhood = neighbourhood_output_queue.get() if isinstance(neighbourhood, NeighbourhoodFailure): failures.append(neighbourhood) else: neighbourhoods.append(neighbourhood) for fetch_thread in fetch_threads: fetch_thread.join() return neighbourhoods, failures class WofUrlNeighbourhoodFetcher(object): def __init__(self, neighbourhood_url, microhood_url, macrohood_url, borough_url, data_url_prefix, n_threads, max_retries): self.neighbourhood_url = neighbourhood_url self.microhood_url = microhood_url self.macrohood_url = macrohood_url self.borough_url = borough_url self.data_url_prefix = data_url_prefix self.n_threads = n_threads self.max_retries = max_retries def fetch_meta_neighbourhoods(self): return fetch_wof_url_meta_neighbourhoods( self.neighbourhood_url, 'neighbourhood', self.max_retries) def fetch_meta_microhoods(self): return fetch_wof_url_meta_neighbourhoods( self.microhood_url, 'microhood', self.max_retries) def fetch_meta_macrohoods(self): return fetch_wof_url_meta_neighbourhoods( self.macrohood_url, 'macrohood', self.max_retries) def fetch_meta_boroughs(self): return fetch_wof_url_meta_neighbourhoods( self.borough_url, 'borough', self.max_retries) def fetch_raw_neighbourhoods(self, neighbourhood_metas): url_fetch_fn = make_fetch_raw_url_fn(self.data_url_prefix, self.max_retries) neighbourhoods, failures = threaded_fetch( neighbourhood_metas, self.n_threads, url_fetch_fn) return neighbourhoods, failures class WofFilesystemNeighbourhoodFetcher(object): def __init__(self, wof_data_path, n_threads): self.wof_data_path = wof_data_path self.n_threads = n_threads def _fetch_meta_neighbourhoods(self, placetype): meta_fs_path = os.path.join( self.wof_data_path, 'meta', 'wof-%s-latest.csv' % placetype) with open(meta_fs_path) as fp: meta_neighbourhoods = list( parse_neighbourhood_meta_csv(fp, placetype)) return meta_neighbourhoods def fetch_meta_neighbourhoods(self): return self._fetch_meta_neighbourhoods('neighbourhood') def fetch_meta_microhoods(self): return self._fetch_meta_neighbourhoods('microhood') def fetch_meta_macrohoods(self): return self._fetch_meta_neighbourhoods('macrohood') def fetch_meta_boroughs(self): return self._fetch_meta_neighbourhoods('borough') def fetch_raw_neighbourhoods(self, neighbourhood_metas): data_prefix = os.path.join( self.wof_data_path, 'data') fs_fetch_fn = make_fetch_raw_filesystem_fn(data_prefix) neighbourhoods, failures = threaded_fetch( neighbourhood_metas, self.n_threads, fs_fetch_fn) return neighbourhoods, failures def create_neighbourhood_file_object(neighbourhoods, curdate=None): if curdate is None: curdate = datetime.now().date() # tell shapely to include the srid when generating WKBs geos.WKBWriter.defaults['include_srid'] = True buf = StringIO() def escape_string(s): return s.encode('utf-8').replace('\t', ' ').replace('\n', ' ') def escape_hstore_string(s): s = escape_string(s) if ' ' in s: s = s.replace('"', '\\\\"') s = '"%s"' % s return s def write_nullable_int(buf, x): if x is None: buf.write('\\N\t') else: buf.write('%d\t' % x) for n in neighbourhoods: buf.write('%d\t' % n.wof_id) buf.write('%d\t' % neighbourhood_placetypes_to_int[n.placetype]) buf.write('%s\t' % escape_string(n.name)) buf.write('%s\t' % escape_string(n.hash)) write_nullable_int(buf, n.n_photos) write_nullable_int(buf, n.area) buf.write('%d\t' % n.min_zoom) buf.write('%d\t' % n.max_zoom) if n.is_landuse_aoi is None: buf.write('\\N\t') else: buf.write('%s\t' % ('true' if n.is_landuse_aoi else 'false')) geos.lgeos.GEOSSetSRID(n.label_position._geom, DATABASE_SRID) buf.write(n.label_position.wkb_hex) buf.write('\t') geos.lgeos.GEOSSetSRID(n.geometry._geom, DATABASE_SRID) buf.write(n.geometry.wkb_hex) buf.write('\t') buf.write('%s\t' % n.inception.isoformat()) buf.write('%s\t' % n.cessation.isoformat()) is_visible = n.inception < curdate and n.cessation >= curdate is_visible_str = 't' if is_visible else 'f' buf.write('%s\t' % is_visible_str) if n.l10n_names: hstore_items = [] for k, v in n.l10n_names.items(): k = escape_hstore_string(k) v = escape_hstore_string(v) hstore_items.append("%s=>%s" % (k, v)) hstore_items_str = ','.join(hstore_items) buf.write('%s' % hstore_items_str) else: buf.write('\\N') buf.write('\n') buf.seek(0) return buf class WofModel(object): def __init__(self, postgresql_conn_info): self.postgresql_conn_info = postgresql_conn_info self.table = 'wof_neighbourhood' def _create_conn(self): conn = psycopg2.connect(**self.postgresql_conn_info) register_hstore(conn) conn.set_session(autocommit=False) return conn def find_previous_neighbourhood_meta(self): with closing(self._create_conn()) as conn: with conn.cursor() as cursor: cursor.execute( 'SELECT wof_id, placetype, name, hash, ' 'ST_AsBinary(label_position) ' 'FROM %s ORDER BY wof_id ASC' % self.table) ns = [] for row in cursor: wof_id, placetype_int, name, hash, label_bytes = row wof_id = int(wof_id) label_bytes = bytes(label_bytes) label_position = shapely.wkb.loads(label_bytes) placetype = neighbourhood_int_to_placetypes[placetype_int] n = NeighbourhoodMeta( wof_id, placetype, name, hash, label_position) ns.append(n) return ns def sync_neighbourhoods( self, neighbourhoods_to_add, neighbourhoods_to_update, ids_to_remove): geos.WKBWriter.defaults['include_srid'] = True def gen_data(n): geos.lgeos.GEOSSetSRID(n.label_position._geom, DATABASE_SRID) geos.lgeos.GEOSSetSRID(n.geometry._geom, DATABASE_SRID) return dict( table=self.table, placetype=neighbourhood_placetypes_to_int[n.placetype], name=n.name, hash=n.hash, n_photos=n.n_photos, area=n.area, min_zoom=n.min_zoom, max_zoom=n.max_zoom, is_landuse_aoi=n.is_landuse_aoi, inception=n.inception, cessation=n.cessation, label_position=n.label_position.wkb_hex, geometry=n.geometry.wkb_hex, wof_id=n.wof_id, l10n_name=n.l10n_names, ) if ids_to_remove: ids_to_remove_str = ', '.join(map(str, ids_to_remove)) if neighbourhoods_to_update: update_data = map(gen_data, neighbourhoods_to_update) if neighbourhoods_to_add: insert_data = map(gen_data, neighbourhoods_to_add) # this closes the connection with closing(self._create_conn()) as conn: # this commits the transaction with conn as conn: # this frees any resources associated with the cursor with conn.cursor() as cursor: if ids_to_remove: cursor.execute( 'DELETE FROM %s WHERE wof_id IN (%s)' % (self.table, ids_to_remove_str)) if neighbourhoods_to_update: cursor.executemany( 'UPDATE ' + self.table + ' SET ' 'placetype=%(placetype)s, ' 'name=%(name)s, ' 'hash=%(hash)s, ' 'n_photos=%(n_photos)s, ' 'area=%(area)s, ' 'min_zoom=%(min_zoom)s, ' 'max_zoom=%(max_zoom)s, ' 'is_landuse_aoi=%(is_landuse_aoi)s, ' 'inception=%(inception)s, ' 'cessation=%(cessation)s, ' 'label_position=%(label_position)s, ' 'l10n_name=%(l10n_name)s, ' 'geometry=%(geometry)s ' 'WHERE wof_id=%(wof_id)s', update_data) if neighbourhoods_to_add: cursor.executemany( 'INSERT INTO ' + self.table + ' ' '(wof_id, placetype, name, hash, n_photos, area, ' 'min_zoom, max_zoom, is_landuse_aoi, ' 'inception, cessation, ' 'label_position, geometry, l10n_name) ' 'VALUES (%(wof_id)s, %(placetype)s, %(name)s, ' '%(hash)s, %(n_photos)s, %(area)s, %(min_zoom)s, ' '%(max_zoom)s, %(is_landuse_aoi)s, ' '%(inception)s, %(cessation)s, ' '%(label_position)s, %(geometry)s, %(l10n_name)s)', insert_data) def insert_neighbourhoods(self, neighbourhoods): # create this whole input file like object outside of the transaction nf = create_neighbourhood_file_object(neighbourhoods) # close the connection with closing(self._create_conn()) as conn: # commit the transaction with conn as conn: with conn.cursor() as cursor: cursor.copy_from(nf, self.table) # update the whole table so that the `is_visible` flag is accurate for the # `current_date`. this returns a list of coords at `zoom` which have # changed visibility from true to false or vice-versa. def update_visible_timestamp(self, zoom, current_date): coords = set() def coord_int(row): x, y = row return coord_int_at_mercator_point(zoom, x, y) # close the connection with closing(self._create_conn()) as conn: # commit the transaction with conn as conn: with conn.cursor() as cursor: # select the x, y position of the label for each WOF # neighbourhood that changed visibility when the date # was updated to `current_date`. cursor.execute( 'SELECT st_x(n.label_position) as x, ' ' st_y(n.label_position) as y ' 'FROM (' ' SELECT wof_update_visible_ids(%s::date) AS id ' ') u ' 'JOIN wof_neighbourhood n ' 'ON n.wof_id = u.id', (current_date.isoformat(),)) for result in cursor: coords.add(coord_int(result)) return coords def diff_neighbourhoods(xs, ys): # NOTE this requires that both xs and ys be sequences of # neighbourhoods, sorted by wof_id in ascending order # returns a sequence of tuples: # (None, x) -> neighbourhoods that have been added # (x, None) -> neighbourhoods that have been removed # (x, y) -> neighbourhoods that have been updated diffs = [] n_xs = len(xs) n_ys = len(ys) idx_xs = 0 idx_ys = 0 # iterate through both lists while we still have values for both while idx_xs < n_xs and idx_ys < n_ys: x = xs[idx_xs] y = ys[idx_ys] if x.wof_id < y.wof_id: diffs.append((x, None)) idx_xs += 1 continue if y.wof_id < x.wof_id: diffs.append((None, y)) idx_ys += 1 continue if x.hash != y.hash: # if there are any differences the hash will be different diffs.append((x, y)) idx_xs += 1 idx_ys += 1 # catch any differences while idx_xs < n_xs: x = xs[idx_xs] diffs.append((x, None)) idx_xs += 1 while idx_ys < n_ys: y = ys[idx_ys] diffs.append((None, y)) idx_ys += 1 return diffs def coord_int_at_mercator_point(z, x, y): coord = mercator_point_to_coord(z, x, y) coord_int = coord_marshall_int(coord) return coord_int def generate_tile_expiry_list(zoom, diffs): coord_ints = set() def add_neighbourhood_diff(n): if n is not None: x = n.label_position.x y = n.label_position.y coord_int = coord_int_at_mercator_point(zoom, x, y) coord_ints.add(coord_int) for n1, n2 in diffs: # for our purposes, we will expire any kind of modification, # whether the neighbourhoods were added, removed, or updated add_neighbourhood_diff(n1) add_neighbourhood_diff(n2) return coord_ints def log_failure(logger, failure): if not (failure.skipped or failure.funky or failure.superseded): failure_message_one_line = failure.message.replace('\n', ' | ') logger.error('Neighbourhood failure for %d: %r - %r' % ( failure.wof_id, failure.reason, failure_message_one_line)) class WofProcessor(object): def __init__(self, fetcher, model, redis_cache_index, intersector, rawr_enqueuer, logger, current_date): self.fetcher = fetcher self.model = model self.redis_cache_index = redis_cache_index self.intersector = intersector self.rawr_enqueuer = rawr_enqueuer self.logger = logger self.zoom_expiry = 16 self.zoom_until = 11 self.current_date = current_date def __call__(self): # perform IO to get old/new neighbourhoods and tiles of # interest in parallel # queues to pass the results through the threads prev_neighbourhoods_queue = Queue.Queue(1) meta_neighbourhoods_queue = Queue.Queue(1) meta_microhoods_queue = Queue.Queue(1) meta_macrohoods_queue = Queue.Queue(1) meta_boroughs_queue = Queue.Queue(1) toi_queue = Queue.Queue(1) # functions for the threads def find_prev_neighbourhoods(): prev_neighbourhoods = ( self.model.find_previous_neighbourhood_meta()) prev_neighbourhoods_queue.put(prev_neighbourhoods) def make_fetch_meta_csv_fn(fn, queue): neighbourhood_metas = list(fn()) queue.put(neighbourhood_metas) def fetch_toi(): toi = self.redis_cache_index.fetch_tiles_of_interest() toi_queue.put(toi) self.logger.info('Fetching tiles of interest in background ...') self.logger.info('Fetching old and new neighbourhoods ...') # start the threads in parallel prev_neighbourhoods_thread = threading.Thread( target=find_prev_neighbourhoods) prev_neighbourhoods_thread.start() meta_neighbourhoods_thread = threading.Thread( target=make_fetch_meta_csv_fn( self.fetcher.fetch_meta_neighbourhoods, meta_neighbourhoods_queue)) meta_neighbourhoods_thread.start() meta_microhoods_thread = threading.Thread( target=make_fetch_meta_csv_fn( self.fetcher.fetch_meta_microhoods, meta_microhoods_queue)) meta_microhoods_thread.start() meta_macrohoods_thread = threading.Thread( target=make_fetch_meta_csv_fn( self.fetcher.fetch_meta_macrohoods, meta_macrohoods_queue)) meta_macrohoods_thread.start() meta_boroughs_thread = threading.Thread( target=make_fetch_meta_csv_fn( self.fetcher.fetch_meta_boroughs, meta_boroughs_queue)) meta_boroughs_thread.start() toi_thread = threading.Thread(target=fetch_toi) toi_thread.start() # ensure we're done with finding the next and previous # neighbourhoods by this point prev_neighbourhoods_thread.join() meta_neighbourhoods_thread.join() meta_microhoods_thread.join() meta_macrohoods_thread.join() meta_boroughs_thread.join() self.logger.info('Fetching old and new neighbourhoods ... done') prev_neighbourhoods = prev_neighbourhoods_queue.get() meta_neighbourhoods = meta_neighbourhoods_queue.get() meta_microhoods = meta_microhoods_queue.get() meta_macrohoods = meta_macrohoods_queue.get() meta_boroughs = meta_boroughs_queue.get() # each of these has the appropriate placetype set now meta_neighbourhoods = ( meta_neighbourhoods + meta_microhoods + meta_macrohoods + meta_boroughs) self.logger.info('Diffing neighbourhoods ...') by_neighborhood_id = attrgetter('wof_id') # the model is expected to return records in ascending order by id # it doesn't seem like the neighbourhoods in the wof csv # are in ascending order, so we sort explicitly here meta_neighbourhoods.sort(key=by_neighborhood_id) # the diff algorithm depends on the neighbourhood lists # being in sorted order by id diffs = diff_neighbourhoods(prev_neighbourhoods, meta_neighbourhoods) self.logger.info('Diffing neighbourhoods ... done') # we need to fetch neighbourhoods that have either been # updated or are new wof_neighbourhoods_to_fetch = [] # based on the diff, we'll need to keep track of how we'll # need to update ids_to_add = set() ids_to_update = set() ids_to_remove = set() for dx, dy in diffs: if dy is not None: if dx is None: ids_to_add.add(dy.wof_id) else: ids_to_update.add(dy.wof_id) wof_neighbourhoods_to_fetch.append(dy) else: ids_to_remove.add(dx.wof_id) if wof_neighbourhoods_to_fetch: self.logger.info('Fetching %d raw neighbourhoods ...' % len(wof_neighbourhoods_to_fetch)) raw_neighbourhoods, failures = ( self.fetcher.fetch_raw_neighbourhoods( wof_neighbourhoods_to_fetch)) self.logger.info('Fetching %d raw neighbourhoods ... done' % len(wof_neighbourhoods_to_fetch)) else: self.logger.info('No raw neighbourhoods found to fetch') raw_neighbourhoods = () failures = [] # we should just remove any neighbourhoods from add/update lists # also keep track of these ids to remove from the diffs too failed_wof_ids = set() superseded_by_wof_ids = set() funky_wof_ids = set() for failure in failures: failure_wof_id = failure.wof_id log_failure(self.logger, failure) if failure.funky: # this scenario is triggered for new neighbourhoods, # or if a neighbourhood became funky # we handle both of these scenarios in tests later on, # but for now we just track the id of the funky # neighbourhoods funky_wof_ids.add(failure_wof_id) if failure.superseded: self.logger.warn( 'superseded_by inconsistency for %s' % failure_wof_id) # this means that we had a value for superseded_by in # the raw json, but not in the meta file # this should get treated as a removal superseded_by_wof_ids.add(failure_wof_id) failed_wof_ids.add(failure_wof_id) ids_to_add.discard(failure_wof_id) ids_to_update.discard(failure_wof_id) # we'll only log the number of funky records that we found if funky_wof_ids: self.logger.warn('Number of funky neighbourhoods: %d' % len(funky_wof_ids)) # now we'll want to ensure that the failed ids are not present # in any additions or updates new_diffs = [] for n1, n2 in diffs: if n2 is None or n2.wof_id not in failed_wof_ids: new_diffs.append((n1, n2)) diffs = new_diffs # and we'll want to also treat any superseded_by # inconsistencies as removals # but we need the original neighbourhood meta object to # generate the diff, for its label position to expire the # appropriate tile if superseded_by_wof_ids: for n in prev_neighbourhoods: if n.wof_id in superseded_by_wof_ids: ids_to_remove.add(n.wof_id) diffs.append((n, None)) # if the neighbourhood became funky and we had it in our # existing set, we'll want to remove it if funky_wof_ids: for n in prev_neighbourhoods: if n.wof_id in funky_wof_ids: ids_to_remove.add(n.wof_id) diffs.append((n, None)) sync_neighbourhoods_thread = None if diffs: self.logger.info("Sync'ing neighbourhoods ...") # raw_neighbourhoods contains both the neighbourhoods to # add and update # we split it up here neighbourhoods_to_update = [] neighbourhoods_to_add = [] for neighbourhood in raw_neighbourhoods: if neighbourhood.wof_id in ids_to_add: neighbourhoods_to_add.append(neighbourhood) elif neighbourhood.wof_id in ids_to_update: neighbourhoods_to_update.append(neighbourhood) else: assert 0, '%d should have been found to add or update' % ( neighbourhood.wof_id) if neighbourhoods_to_add: self.logger.info('Inserting neighbourhoods: %d' % len(neighbourhoods_to_add)) if neighbourhoods_to_update: self.logger.info('Updating neighbourhoods: %d' % len(neighbourhoods_to_update)) if ids_to_remove: self.logger.info('Removing neighbourhoods: %d' % len(ids_to_remove)) def _sync_neighbourhoods(): self.model.sync_neighbourhoods( neighbourhoods_to_add, neighbourhoods_to_update, ids_to_remove) sync_neighbourhoods_thread = threading.Thread( target=_sync_neighbourhoods) sync_neighbourhoods_thread.start() else: self.logger.info('No diffs found, no sync necessary') if diffs: self.logger.info('Generating tile expiry list ...') expired_coord_ints = generate_tile_expiry_list( self.zoom_expiry, diffs) self.logger.info( 'Generating tile expiry list ... done - ' 'Found %d expired tiles' % len(expired_coord_ints)) else: self.logger.info('No diffs found, not generating expired coords') expired_coord_ints = set() # ensure we're done fetching the tiles of interest by this point toi_thread.join() toi = toi_queue.get() self.logger.info('Have tiles of interest') # we need to finish sync'ing neighbourhoods before we flip the # visibility flag and enqueue coordinates if sync_neighbourhoods_thread is not None: sync_neighbourhoods_thread.join() self.logger.info("Sync'ing neighbourhoods ... done") # update the current timestamp, returning the list of coords that # have changed visibility. visibility_updates = \ self.model.update_visible_timestamp( self.zoom_expiry, self.current_date) self.logger.info('Have %d tile expiries from visibility changes.' % len(visibility_updates)) expired_coord_ints.update(visibility_updates) if diffs: # intersect the tiles of interest with the expired coords from # the neighbourhood diff self.logger.info('Intersecting %d tiles of interest with %d ' 'expired tiles' % ( len(toi), len(expired_coord_ints))) toi_expired_coord_ints, _ = self.intersector( expired_coord_ints, toi, self.zoom_until) coords = map(coord_unmarshall_int, toi_expired_coord_ints) self.logger.info('Intersection complete, will expire %d tiles' % len(coords)) else: self.logger.info('No diffs found, no need to intersect') coords = () if coords: self.logger.info('Asking enqueuer to enqueue %d coords ...' % len(coords)) self.rawr_enqueuer(coords) self.logger.info('Asking enqueuer to enqueue %d coords ... done' % len(coords)) else: self.logger.info('No expired tiles to enqueue') class WofInitialLoader(object): def __init__(self, fetcher, model, logger): self.fetcher = fetcher self.model = model self.logger = logger def __call__(self): self.logger.info('Fetching meta neighbourhoods csv ...') neighbourhood_metas = list(self.fetcher.fetch_meta_neighbourhoods()) self.logger.info('Fetching meta neighbourhoods csv ... done') self.logger.info('Fetching meta microhoods csv ...') microhood_metas = list(self.fetcher.fetch_meta_microhoods()) self.logger.info('Fetching meta microhoods csv ... done') self.logger.info('Fetching meta macrohoods csv ...') macrohood_metas = list(self.fetcher.fetch_meta_macrohoods()) self.logger.info('Fetching meta macrohoods csv ... done') self.logger.info('Fetching meta boroughs csv ...') borough_metas = list(self.fetcher.fetch_meta_boroughs()) self.logger.info('Fetching meta boroughs csv ... done') neighbourhood_metas = ( neighbourhood_metas + microhood_metas + macrohood_metas + borough_metas) self.logger.info('Fetching raw neighbourhoods ...') neighbourhoods, failures = self.fetcher.fetch_raw_neighbourhoods( neighbourhood_metas) for failure in failures: log_failure(self.logger, failure) self.logger.info('Fetching raw neighbourhoods ... done') self.logger.info('Inserting %d neighbourhoods ...' % len(neighbourhoods)) self.model.insert_neighbourhoods(neighbourhoods) self.logger.info('Inserting %d neighbourhoods ... done' % len(neighbourhoods)) def make_wof_url_neighbourhood_fetcher( neighbourhood_url, microhood_url, macrohood_url, borough_url, data_prefix_url, n_threads, max_retries): fetcher = WofUrlNeighbourhoodFetcher( neighbourhood_url, microhood_url, macrohood_url, borough_url, data_prefix_url, n_threads, max_retries) return fetcher def make_wof_filesystem_neighbourhood_fetcher(wof_data_path, n_threads): fetcher = WofFilesystemNeighbourhoodFetcher( wof_data_path, n_threads) return fetcher def make_wof_model(postgresql_conn_info): wof_model = WofModel(postgresql_conn_info) return wof_model def make_wof_processor( fetcher, model, redis_cache_index, rawr_enqueuer, logger, current_date): from tilequeue.command import explode_and_intersect wof_processor = WofProcessor( fetcher, model, redis_cache_index, explode_and_intersect, rawr_enqueuer, logger, current_date) return wof_processor def make_wof_initial_loader(fetcher, model, logger): wof_loader = WofInitialLoader(fetcher, model, logger) return wof_loader
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 5055, 492, 12863, 199, 504, 15502, 492, 11261, 199, 504, 15073, 492, 5228, 199, 504, 2197, 492, 2197, 199, 504, 3988, 3249, 492, 2198, 63, 379, 3249, 199, 504, 4182, 492, 21829, 199, 504, 15492, 18, 14, 9975, 492, 2274, 63, 72, 1617, 199, 504, 2215, 590, 492, 30259, 199, 504, 12835, 1825, 14, 7172, 492, 11021, 63, 28128, 452, 63, 442, 199, 504, 12835, 1825, 14, 7172, 492, 11021, 63, 324, 28128, 452, 63, 442, 199, 504, 12835, 1825, 14, 7172, 492, 562, 1195, 707, 63, 1403, 63, 475, 63, 7988, 199, 504, 12835, 1825, 14, 7172, 492, 295, 1715, 63, 23829, 4452, 63, 475, 63, 278, 1195, 707, 199, 646, 7392, 199, 646, 2022, 199, 646, 747, 14, 515, 199, 646, 15492, 18, 199, 646, 10703, 199, 646, 4145, 199, 646, 2215, 590, 14, 7660, 199, 646, 2215, 590, 14, 1483, 199, 646, 2215, 590, 14, 18914, 199, 646, 5796, 421, 199, 17873, 63, 5943, 998, 275, 10448, 1641, 421, 199, 318, 3550, 63, 4737, 63, 1278, 8, 6615, 63, 1099, 304, 272, 367, 1004, 315, 4145, 63, 1099, 14, 1661, 63, 1278, 837, 267, 340, 1004, 26, 288, 1995, 1004, 421, 199, 685, 4594, 567, 10422, 63, 2778, 1313, 63, 475, 63, 442, 275, 1211, 8, 272, 1279, 4594, 567, 10422, 29, 17, 12, 272, 9967, 10422, 29, 18, 12, 272, 9559, 10422, 29, 19, 12, 272, 330, 269, 4937, 29, 20, 12, 199, 9, 199, 685, 4594, 567, 10422, 63, 442, 63, 475, 63, 2778, 1313, 275, 469, 272, 413, 26, 283, 685, 4594, 567, 10422, 297, 272, 499, 26, 283, 6453, 10422, 297, 272, 650, 26, 283, 11300, 10422, 297, 272, 841, 26, 283, 31938, 4937, 297, 199, 93, 421, 199, 4698, 4594, 567, 10422, 3396, 275, 12863, 8, 272, 283, 4698, 4594, 567, 10422, 3396, 297, 272, 283, 87, 1618, 63, 344, 4192, 466, 536, 2631, 1768, 63, 3124, 358, 199, 4698, 4594, 567, 10422, 275, 12863, 8, 272, 283, 4698, 4594, 567, 10422, 297, 272, 283, 87, 1618, 63, 344, 4192, 466, 536, 2631, 1768, 63, 3124, 3400, 302, 63, 25211, 9150, 283, 272, 283, 827, 63, 10598, 1390, 63, 10598, 365, 63, 9688, 1180, 63, 8035, 73, 315, 814, 10142, 385, 425, 634, 709, 78, 63, 1247, 358, 421, 199, 318, 2198, 63, 685, 4594, 567, 10422, 63, 2024, 63, 4737, 8, 4737, 63, 604, 63, 4679, 12, 4192, 466, 304, 272, 7002, 275, 7392, 14, 5503, 8, 4737, 63, 604, 63, 4679, 9, 339, 652, 275, 2740, 8, 5503, 9, 272, 1406, 275, 652, 14, 2184, 342, 339, 32375, 63, 4452, 63, 2996, 275, 1406, 14, 1080, 360, 18842, 63, 13331, 358, 272, 32375, 63, 23829, 63, 2996, 275, 1406, 14, 1080, 360, 18842, 63, 13803, 358, 272, 536, 63, 2996, 275, 1406, 14, 1080, 360, 354, 358, 272, 336, 1618, 63, 344, 63, 2996, 275, 1406, 14, 1080, 360, 344, 358, 272, 2631, 63, 2996, 275, 1406, 14, 1080, 360, 493, 63, 2227, 358, 272, 1613, 261, 770, 63, 991, 63, 2996, 275, 1406, 14, 1080, 360, 4792, 261, 770, 63, 991, 358, 339, 1748, 63, 1143, 63, 1267, 275, 334, 988, 8, 267, 32375, 63, 4452, 63, 2996, 12, 32375, 63, 23829, 63, 2996, 12, 536, 63, 2996, 12, 336, 1618, 63, 344, 63, 2996, 12, 2631, 63, 2996, 12, 267, 1613, 261, 770, 63, 991, 63, 2996, 9, 435, 413, 9, 339, 367, 1962, 315, 652, 26, 267, 340, 822, 8, 1143, 9, 665, 1748, 63, 1143, 63, 1267, 26, 288, 1980, 398, 1613, 261, 770, 63, 991, 275, 1962, 59, 4792, 261, 770, 63, 991, 63, 2996, 61, 267, 340, 1613, 261, 770, 63, 991, 26, 288, 1980, 398, 336, 1618, 63, 344, 63, 495, 275, 1962, 59, 87, 1618, 63, 344, 63, 2996, 61, 267, 340, 440, 336, 1618, 63, 344, 63, 495, 26, 288, 1980, 267, 862, 26, 288, 336, 1618, 63, 344, 275, 1109, 8, 87, 1618, 63, 344, 63, 495, 9, 267, 871, 1722, 26, 288, 1980, 398, 536, 275, 1962, 59, 354, 63, 2996, 61, 267, 340, 440, 536, 26, 288, 1980, 398, 8396, 63, 495, 275, 1962, 59, 18842, 63, 4452, 63, 2996, 61, 267, 634, 2753, 63, 495, 275, 1962, 59, 18842, 63, 23829, 63, 2996, 61, 267, 862, 26, 288, 8396, 275, 2069, 8, 4452, 63, 495, 9, 288, 634, 2753, 275, 2069, 8, 23829, 63, 495, 9, 267, 871, 1722, 26, 288, 1980, 398, 570, 63, 2227, 275, 1962, 59, 2227, 63, 2996, 61, 398, 1768, 63, 88, 12, 1768, 63, 89, 275, 295, 1715, 63, 23829, 4452, 63, 475, 63, 278, 1195, 707, 8, 23829, 12, 8396, 9, 267, 1768, 63, 3124, 275, 2215, 590, 14, 7660, 14, 3428, 8, 1302, 63, 88, 12, 1768, 63, 89, 9, 398, 1279, 4594, 567, 10422, 63, 2024, 275, 5612, 4594, 567, 10422, 3396, 8, 288, 336, 1618, 63, 344, 12, 4192, 466, 12, 536, 12, 570, 63, 2227, 12, 1768, 63, 3124, 9, 267, 1995, 1279, 4594, 567, 10422, 63, 2024, 421, 199, 318, 485, 1875, 63, 6615, 63, 1730, 63, 1045, 63, 10937, 8, 988, 63, 10937, 304, 272, 687, 4145, 14, 21680, 492, 3101, 10200, 272, 687, 4145, 14, 5154, 14, 4078, 19, 14, 1974, 492, 20506, 339, 308, 275, 4145, 14, 4434, 342, 272, 282, 275, 3101, 10200, 8, 267, 1390, 63, 10937, 29, 12989, 8, 288, 3141, 29, 988, 63, 10937, 12, 288, 2004, 63, 3990, 513, 1524, 221, 327, 642, 365, 282, 769, 402, 24498, 370, 11201, 370, 506, 1816, 327, 376, 1125, 436, 7269, 14, 355, 17640, 12, 221, 327, 22893, 5002, 4145, 334, 73, 14, 69, 26, 1771, 2331, 9, 355, 6891, 12, 221, 327, 8307, 5007, 1654, 1125, 355, 959, 996, 12, 221, 327, 8857, 27166, 446, 284, 14, 69, 26, 18932, 5988, 355, 24046, 12, 221, 327, 1910, 4561, 12, 22256, 355, 959, 966, 12, 221, 327, 27166, 2653, 355, 959, 1081, 257, 327, 31534, 1950, 18590, 734, 288, 2156, 288, 22735, 63, 4778, 29, 17, 14, 16, 221, 327, 1771, 2331, 367, 378, 83, 12, 413, 83, 12, 650, 83, 12, 1520, 83 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 5055, 492, 12863, 199, 504, 15502, 492, 11261, 199, 504, 15073, 492, 5228, 199, 504, 2197, 492, 2197, 199, 504, 3988, 3249, 492, 2198, 63, 379, 3249, 199, 504, 4182, 492, 21829, 199, 504, 15492, 18, 14, 9975, 492, 2274, 63, 72, 1617, 199, 504, 2215, 590, 492, 30259, 199, 504, 12835, 1825, 14, 7172, 492, 11021, 63, 28128, 452, 63, 442, 199, 504, 12835, 1825, 14, 7172, 492, 11021, 63, 324, 28128, 452, 63, 442, 199, 504, 12835, 1825, 14, 7172, 492, 562, 1195, 707, 63, 1403, 63, 475, 63, 7988, 199, 504, 12835, 1825, 14, 7172, 492, 295, 1715, 63, 23829, 4452, 63, 475, 63, 278, 1195, 707, 199, 646, 7392, 199, 646, 2022, 199, 646, 747, 14, 515, 199, 646, 15492, 18, 199, 646, 10703, 199, 646, 4145, 199, 646, 2215, 590, 14, 7660, 199, 646, 2215, 590, 14, 1483, 199, 646, 2215, 590, 14, 18914, 199, 646, 5796, 421, 199, 17873, 63, 5943, 998, 275, 10448, 1641, 421, 199, 318, 3550, 63, 4737, 63, 1278, 8, 6615, 63, 1099, 304, 272, 367, 1004, 315, 4145, 63, 1099, 14, 1661, 63, 1278, 837, 267, 340, 1004, 26, 288, 1995, 1004, 421, 199, 685, 4594, 567, 10422, 63, 2778, 1313, 63, 475, 63, 442, 275, 1211, 8, 272, 1279, 4594, 567, 10422, 29, 17, 12, 272, 9967, 10422, 29, 18, 12, 272, 9559, 10422, 29, 19, 12, 272, 330, 269, 4937, 29, 20, 12, 199, 9, 199, 685, 4594, 567, 10422, 63, 442, 63, 475, 63, 2778, 1313, 275, 469, 272, 413, 26, 283, 685, 4594, 567, 10422, 297, 272, 499, 26, 283, 6453, 10422, 297, 272, 650, 26, 283, 11300, 10422, 297, 272, 841, 26, 283, 31938, 4937, 297, 199, 93, 421, 199, 4698, 4594, 567, 10422, 3396, 275, 12863, 8, 272, 283, 4698, 4594, 567, 10422, 3396, 297, 272, 283, 87, 1618, 63, 344, 4192, 466, 536, 2631, 1768, 63, 3124, 358, 199, 4698, 4594, 567, 10422, 275, 12863, 8, 272, 283, 4698, 4594, 567, 10422, 297, 272, 283, 87, 1618, 63, 344, 4192, 466, 536, 2631, 1768, 63, 3124, 3400, 302, 63, 25211, 9150, 283, 272, 283, 827, 63, 10598, 1390, 63, 10598, 365, 63, 9688, 1180, 63, 8035, 73, 315, 814, 10142, 385, 425, 634, 709, 78, 63, 1247, 358, 421, 199, 318, 2198, 63, 685, 4594, 567, 10422, 63, 2024, 63, 4737, 8, 4737, 63, 604, 63, 4679, 12, 4192, 466, 304, 272, 7002, 275, 7392, 14, 5503, 8, 4737, 63, 604, 63, 4679, 9, 339, 652, 275, 2740, 8, 5503, 9, 272, 1406, 275, 652, 14, 2184, 342, 339, 32375, 63, 4452, 63, 2996, 275, 1406, 14, 1080, 360, 18842, 63, 13331, 358, 272, 32375, 63, 23829, 63, 2996, 275, 1406, 14, 1080, 360, 18842, 63, 13803, 358, 272, 536, 63, 2996, 275, 1406, 14, 1080, 360, 354, 358, 272, 336, 1618, 63, 344, 63, 2996, 275, 1406, 14, 1080, 360, 344, 358, 272, 2631, 63, 2996, 275, 1406, 14, 1080, 360, 493, 63, 2227, 358, 272, 1613, 261, 770, 63, 991, 63, 2996, 275, 1406, 14, 1080, 360, 4792, 261, 770, 63, 991, 358, 339, 1748, 63, 1143, 63, 1267, 275, 334, 988, 8, 267, 32375, 63, 4452, 63, 2996, 12, 32375, 63, 23829, 63, 2996, 12, 536, 63, 2996, 12, 336, 1618, 63, 344, 63, 2996, 12, 2631, 63, 2996, 12, 267, 1613, 261, 770, 63, 991, 63, 2996, 9, 435, 413, 9, 339, 367, 1962, 315, 652, 26, 267, 340, 822, 8, 1143, 9, 665, 1748, 63, 1143, 63, 1267, 26, 288, 1980, 398, 1613, 261, 770, 63, 991, 275, 1962, 59, 4792, 261, 770, 63, 991, 63, 2996, 61, 267, 340, 1613, 261, 770, 63, 991, 26, 288, 1980, 398, 336, 1618, 63, 344, 63, 495, 275, 1962, 59, 87, 1618, 63, 344, 63, 2996, 61, 267, 340, 440, 336, 1618, 63, 344, 63, 495, 26, 288, 1980, 267, 862, 26, 288, 336, 1618, 63, 344, 275, 1109, 8, 87, 1618, 63, 344, 63, 495, 9, 267, 871, 1722, 26, 288, 1980, 398, 536, 275, 1962, 59, 354, 63, 2996, 61, 267, 340, 440, 536, 26, 288, 1980, 398, 8396, 63, 495, 275, 1962, 59, 18842, 63, 4452, 63, 2996, 61, 267, 634, 2753, 63, 495, 275, 1962, 59, 18842, 63, 23829, 63, 2996, 61, 267, 862, 26, 288, 8396, 275, 2069, 8, 4452, 63, 495, 9, 288, 634, 2753, 275, 2069, 8, 23829, 63, 495, 9, 267, 871, 1722, 26, 288, 1980, 398, 570, 63, 2227, 275, 1962, 59, 2227, 63, 2996, 61, 398, 1768, 63, 88, 12, 1768, 63, 89, 275, 295, 1715, 63, 23829, 4452, 63, 475, 63, 278, 1195, 707, 8, 23829, 12, 8396, 9, 267, 1768, 63, 3124, 275, 2215, 590, 14, 7660, 14, 3428, 8, 1302, 63, 88, 12, 1768, 63, 89, 9, 398, 1279, 4594, 567, 10422, 63, 2024, 275, 5612, 4594, 567, 10422, 3396, 8, 288, 336, 1618, 63, 344, 12, 4192, 466, 12, 536, 12, 570, 63, 2227, 12, 1768, 63, 3124, 9, 267, 1995, 1279, 4594, 567, 10422, 63, 2024, 421, 199, 318, 485, 1875, 63, 6615, 63, 1730, 63, 1045, 63, 10937, 8, 988, 63, 10937, 304, 272, 687, 4145, 14, 21680, 492, 3101, 10200, 272, 687, 4145, 14, 5154, 14, 4078, 19, 14, 1974, 492, 20506, 339, 308, 275, 4145, 14, 4434, 342, 272, 282, 275, 3101, 10200, 8, 267, 1390, 63, 10937, 29, 12989, 8, 288, 3141, 29, 988, 63, 10937, 12, 288, 2004, 63, 3990, 513, 1524, 221, 327, 642, 365, 282, 769, 402, 24498, 370, 11201, 370, 506, 1816, 327, 376, 1125, 436, 7269, 14, 355, 17640, 12, 221, 327, 22893, 5002, 4145, 334, 73, 14, 69, 26, 1771, 2331, 9, 355, 6891, 12, 221, 327, 8307, 5007, 1654, 1125, 355, 959, 996, 12, 221, 327, 8857, 27166, 446, 284, 14, 69, 26, 18932, 5988, 355, 24046, 12, 221, 327, 1910, 4561, 12, 22256, 355, 959, 966, 12, 221, 327, 27166, 2653, 355, 959, 1081, 257, 327, 31534, 1950, 18590, 734, 288, 2156, 288, 22735, 63, 4778, 29, 17, 14, 16, 221, 327, 1771, 2331, 367, 378, 83, 12, 413, 83, 12, 650, 83, 12, 1520, 83, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lra/boto
tests/integration/elasticache/test_layer1.py
113
2728
# Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # import time from tests.unit import unittest from boto.elasticache import layer1 from boto.exception import BotoServerError class TestElastiCacheConnection(unittest.TestCase): def setUp(self): self.elasticache = layer1.ElastiCacheConnection() def wait_until_cluster_available(self, cluster_id): timeout = time.time() + 600 while time.time() < timeout: response = self.elasticache.describe_cache_clusters(cluster_id) status = (response['DescribeCacheClustersResponse'] ['DescribeCacheClustersResult'] ['CacheClusters'][0]['CacheClusterStatus']) if status == 'available': break time.sleep(5) else: self.fail('Timeout waiting for cache cluster %r' 'to become available.' % cluster_id) def test_create_delete_cache_cluster(self): cluster_id = 'cluster-id2' self.elasticache.create_cache_cluster( cluster_id, 1, 'cache.t1.micro', 'memcached') self.wait_until_cluster_available(cluster_id) self.elasticache.delete_cache_cluster(cluster_id) timeout = time.time() + 600 while time.time() < timeout: try: self.elasticache.describe_cache_clusters(cluster_id) except BotoServerError: break time.sleep(5) else: self.fail('Timeout waiting for cache cluster %s' 'to be deleted.' % cluster_id) if __name__ == '__main__': unittest.main()
mit
[ 3, 1898, 334, 67, 9, 6171, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 646, 900, 199, 504, 2295, 14, 3248, 492, 2882, 199, 199, 504, 6055, 14, 15565, 21481, 492, 4045, 17, 199, 504, 6055, 14, 1971, 492, 24411, 17692, 421, 199, 533, 1379, 37, 2019, 73, 4437, 3225, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 15565, 21481, 275, 4045, 17, 14, 37, 2019, 73, 4437, 3225, 342, 339, 347, 3618, 63, 8111, 63, 4201, 63, 4561, 8, 277, 12, 4350, 63, 344, 304, 267, 2653, 275, 900, 14, 521, 342, 435, 11624, 267, 1830, 900, 14, 521, 342, 665, 2653, 26, 288, 1177, 275, 291, 14, 15565, 21481, 14, 11935, 63, 1637, 63, 9170, 8, 4201, 63, 344, 9, 288, 2004, 275, 334, 1310, 459, 19506, 4437, 1968, 6811, 2364, 418, 2892, 788, 19506, 4437, 1968, 6811, 2889, 418, 2892, 788, 4437, 1968, 6811, 3488, 16, 2733, 4437, 9581, 3694, 1105, 288, 340, 2004, 508, 283, 4561, 356, 355, 2059, 288, 900, 14, 4532, 8, 21, 9, 267, 587, 26, 288, 291, 14, 1633, 360, 6372, 10923, 367, 2581, 4350, 450, 82, 7, 1993, 283, 475, 8649, 2808, 3530, 450, 4350, 63, 344, 9, 339, 347, 511, 63, 981, 63, 1807, 63, 1637, 63, 4201, 8, 277, 304, 267, 4350, 63, 344, 275, 283, 4201, 13, 344, 18, 7, 267, 291, 14, 15565, 21481, 14, 981, 63, 1637, 63, 4201, 8, 288, 4350, 63, 344, 12, 413, 12, 283, 1637, 14, 84, 17, 14, 6453, 297, 283, 32567, 358, 267, 291, 14, 2573, 63, 8111, 63, 4201, 63, 4561, 8, 4201, 63, 344, 9, 398, 291, 14, 15565, 21481, 14, 1807, 63, 1637, 63, 4201, 8, 4201, 63, 344, 9, 267, 2653, 275, 900, 14, 521, 342, 435, 11624, 267, 1830, 900, 14, 521, 342, 665, 2653, 26, 288, 862, 26, 355, 291, 14, 15565, 21481, 14, 11935, 63, 1637, 63, 9170, 8, 4201, 63, 344, 9, 288, 871, 24411, 17692, 26, 355, 2059, 288, 900, 14, 4532, 8, 21, 9, 267, 587, 26, 288, 291, 14, 1633, 360, 6372, 10923, 367, 2581, 4350, 450, 83, 7, 1993, 283, 475, 506, 5463, 3530, 450, 4350, 63, 344, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6171, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 646, 900, 199, 504, 2295, 14, 3248, 492, 2882, 199, 199, 504, 6055, 14, 15565, 21481, 492, 4045, 17, 199, 504, 6055, 14, 1971, 492, 24411, 17692, 421, 199, 533, 1379, 37, 2019, 73, 4437, 3225, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 15565, 21481, 275, 4045, 17, 14, 37, 2019, 73, 4437, 3225, 342, 339, 347, 3618, 63, 8111, 63, 4201, 63, 4561, 8, 277, 12, 4350, 63, 344, 304, 267, 2653, 275, 900, 14, 521, 342, 435, 11624, 267, 1830, 900, 14, 521, 342, 665, 2653, 26, 288, 1177, 275, 291, 14, 15565, 21481, 14, 11935, 63, 1637, 63, 9170, 8, 4201, 63, 344, 9, 288, 2004, 275, 334, 1310, 459, 19506, 4437, 1968, 6811, 2364, 418, 2892, 788, 19506, 4437, 1968, 6811, 2889, 418, 2892, 788, 4437, 1968, 6811, 3488, 16, 2733, 4437, 9581, 3694, 1105, 288, 340, 2004, 508, 283, 4561, 356, 355, 2059, 288, 900, 14, 4532, 8, 21, 9, 267, 587, 26, 288, 291, 14, 1633, 360, 6372, 10923, 367, 2581, 4350, 450, 82, 7, 1993, 283, 475, 8649, 2808, 3530, 450, 4350, 63, 344, 9, 339, 347, 511, 63, 981, 63, 1807, 63, 1637, 63, 4201, 8, 277, 304, 267, 4350, 63, 344, 275, 283, 4201, 13, 344, 18, 7, 267, 291, 14, 15565, 21481, 14, 981, 63, 1637, 63, 4201, 8, 288, 4350, 63, 344, 12, 413, 12, 283, 1637, 14, 84, 17, 14, 6453, 297, 283, 32567, 358, 267, 291, 14, 2573, 63, 8111, 63, 4201, 63, 4561, 8, 4201, 63, 344, 9, 398, 291, 14, 15565, 21481, 14, 1807, 63, 1637, 63, 4201, 8, 4201, 63, 344, 9, 267, 2653, 275, 900, 14, 521, 342, 435, 11624, 267, 1830, 900, 14, 521, 342, 665, 2653, 26, 288, 862, 26, 355, 291, 14, 15565, 21481, 14, 11935, 63, 1637, 63, 9170, 8, 4201, 63, 344, 9, 288, 871, 24411, 17692, 26, 355, 2059, 288, 900, 14, 4532, 8, 21, 9, 267, 587, 26, 288, 291, 14, 1633, 360, 6372, 10923, 367, 2581, 4350, 450, 83, 7, 1993, 283, 475, 506, 5463, 3530, 450, 4350, 63, 344, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Tala/bybop
src/interactive.py
1
1944
#!/usr/bin/env python import sys try: import readline except ImportError: import pyreadline as readline import os import code import rlcompleter lib_path = os.path.abspath(os.path.join('..', 'src')) sys.path.append(lib_path) lib_path = os.path.abspath(os.path.join('..', '..', 'ARSDKBuildUtils', 'Utils', 'Python')) sys.path.append(lib_path) from Bybop_Discovery import * import Bybop_Device print('Searching for devices') from zeroconf import ZeroconfServiceTypes print('\n'.join(ZeroconfServiceTypes.find())) print('done.') discovery = Discovery([DeviceID.BEBOP_DRONE, DeviceID.JUMPING_SUMO, DeviceID.AIRBORNE_NIGHT, DeviceID.JUMPING_NIGHT]) discovery.wait_for_change() devices = discovery.get_devices() #discovery.stop() if not devices: print('Oops ...') sys.exit(1) device = devices.itervalues().next() print('Will connect to ' + get_name(device)) d2c_port = 43210 controller_type = "PC" controller_name = "bybop shell" drone = Bybop_Device.create_and_connect(device, d2c_port, controller_type, controller_name) if drone is None: print('Unable to connect to a product') sys.exit(1) drone.dump_state() vars = globals().copy() vars.update(locals()) readline.set_completer(rlcompleter.Completer(vars).complete) readline.parse_and_bind("tab: complete") shell = code.InteractiveConsole(vars) # drone.jump(0) # jump forward # drone.jump(1) # jump up # drone.move_forward(20) # move forwards # drone.move_forward(-20) # move backwards # drone.move(0,50) # turn right? # drone.move(0,-50) # turn left? # drone.spin() # spin around # drone.simpleAnimation(0) # drone.simpleAnimation(9) # Currently known values: # - 0 : stop # - 1 : spin # - 2 : tap # - 3 : slowshake # - 4 : metronome # - 5 : ondulation # - 6 : spinjump # - 7 : spintoposture # - 8 : spiral # - 9 : slalom # """ shell.interact() drone.stop()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 893, 26, 272, 492, 14441, 199, 2590, 3545, 26, 272, 492, 1134, 6407, 465, 14441, 199, 646, 747, 199, 199, 646, 1233, 199, 646, 25717, 18452, 199, 199, 773, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 24893, 297, 283, 2164, 1333, 199, 1274, 14, 515, 14, 740, 8, 773, 63, 515, 9, 199, 199, 773, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 24893, 297, 19155, 283, 689, 14939, 3425, 7535, 297, 283, 7535, 297, 283, 4718, 1333, 199, 1274, 14, 515, 14, 740, 8, 773, 63, 515, 9, 199, 199, 504, 4885, 66, 411, 63, 2825, 6913, 492, 627, 199, 646, 4885, 66, 411, 63, 2510, 199, 199, 1361, 360, 5278, 316, 367, 7256, 358, 199, 199, 504, 4697, 2190, 492, 15708, 2190, 3167, 4100, 199, 1361, 2258, 78, 1370, 904, 8, 8681, 2190, 3167, 4100, 14, 1623, 4059, 199, 1361, 360, 4456, 2659, 199, 199, 14859, 275, 5289, 6913, 779, 2510, 998, 14, 6773, 34, 1938, 63, 4564, 4817, 12, 12272, 998, 14, 42, 22759, 1206, 63, 13285, 47, 12, 12272, 998, 14, 33, 3927, 34, 726, 6388, 63, 46, 2830, 12, 12272, 998, 14, 42, 22759, 1206, 63, 46, 2830, 566, 199, 199, 14859, 14, 2573, 63, 509, 63, 1461, 342, 199, 199, 6410, 275, 13172, 14, 362, 63, 6410, 342, 199, 199, 3, 14859, 14, 2379, 342, 199, 199, 692, 440, 7256, 26, 272, 870, 360, 47, 1483, 2263, 358, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1782, 275, 7256, 14, 13012, 1252, 2184, 342, 199, 199, 1361, 360, 20326, 4907, 370, 283, 435, 664, 63, 354, 8, 1782, 430, 199, 199, 68, 18, 67, 63, 719, 275, 841, 708, 709, 199, 5538, 63, 466, 275, 298, 4222, 2, 199, 5538, 63, 354, 275, 298, 991, 66, 411, 5218, 2, 199, 199, 5012, 368, 275, 4885, 66, 411, 63, 2510, 14, 981, 63, 460, 63, 2242, 8, 1782, 12, 366, 18, 67, 63, 719, 12, 7614, 63, 466, 12, 7614, 63, 354, 9, 199, 199, 692, 16642, 368, 365, 488, 26, 272, 870, 360, 6005, 370, 4907, 370, 282, 3336, 358, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 5012, 368, 14, 2724, 63, 929, 342, 199, 199, 2936, 275, 7992, 1252, 1574, 342, 199, 2936, 14, 873, 8, 9350, 1012, 199, 6407, 14, 409, 63, 18452, 8, 4308, 18452, 14, 6600, 351, 8, 2936, 680, 4883, 9, 199, 6407, 14, 1122, 63, 460, 63, 3409, 480, 2902, 26, 4890, 531, 199, 5641, 275, 1233, 14, 23879, 9270, 8, 2936, 9, 199, 199, 3, 16642, 368, 14, 11126, 8, 16, 9, 221, 327, 14882, 7568, 199, 3, 16642, 368, 14, 11126, 8, 17, 9, 221, 327, 14882, 1536, 199, 3, 16642, 368, 14, 1185, 63, 6688, 8, 1165, 9, 221, 327, 4057, 17465, 199, 3, 16642, 368, 14, 1185, 63, 6688, 2801, 1165, 9, 221, 327, 4057, 8552, 199, 3, 16642, 368, 14, 1185, 8, 16, 12, 1400, 9, 221, 327, 7485, 2451, 31, 199, 3, 16642, 368, 14, 1185, 8, 16, 3057, 1400, 9, 221, 327, 7485, 3602, 31, 199, 3, 16642, 368, 14, 14809, 342, 327, 20749, 6818, 199, 3, 16642, 368, 14, 4129, 15957, 8, 16, 9, 199, 3, 16642, 368, 14, 4129, 15957, 8, 25, 9, 199, 3, 13550, 6040, 1338, 26, 199, 3, 260, 446, 378, 520, 3631, 199, 3, 260, 446, 413, 520, 20749, 199, 3, 260, 446, 499, 520, 24410, 199, 3, 260, 446, 650, 520, 11999, 7228, 199, 3, 260, 446, 841, 520, 562, 454, 265, 1377, 199, 3, 260, 446, 959, 520, 641, 68, 5332, 199, 3, 260, 446, 1227, 520, 20749, 11126, 199, 3, 260, 446, 1520, 520, 2249, 442, 411, 941, 608, 199, 3, 260, 446, 1695, 520, 2249, 723, 279, 199, 3, 260, 446, 1749, 520, 5340, 279, 676, 199, 3, 260, 408, 199, 199, 5641, 14, 25850, 342, 199, 5012, 368, 14, 2379, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 893, 26, 272, 492, 14441, 199, 2590, 3545, 26, 272, 492, 1134, 6407, 465, 14441, 199, 646, 747, 199, 199, 646, 1233, 199, 646, 25717, 18452, 199, 199, 773, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 24893, 297, 283, 2164, 1333, 199, 1274, 14, 515, 14, 740, 8, 773, 63, 515, 9, 199, 199, 773, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 24893, 297, 19155, 283, 689, 14939, 3425, 7535, 297, 283, 7535, 297, 283, 4718, 1333, 199, 1274, 14, 515, 14, 740, 8, 773, 63, 515, 9, 199, 199, 504, 4885, 66, 411, 63, 2825, 6913, 492, 627, 199, 646, 4885, 66, 411, 63, 2510, 199, 199, 1361, 360, 5278, 316, 367, 7256, 358, 199, 199, 504, 4697, 2190, 492, 15708, 2190, 3167, 4100, 199, 1361, 2258, 78, 1370, 904, 8, 8681, 2190, 3167, 4100, 14, 1623, 4059, 199, 1361, 360, 4456, 2659, 199, 199, 14859, 275, 5289, 6913, 779, 2510, 998, 14, 6773, 34, 1938, 63, 4564, 4817, 12, 12272, 998, 14, 42, 22759, 1206, 63, 13285, 47, 12, 12272, 998, 14, 33, 3927, 34, 726, 6388, 63, 46, 2830, 12, 12272, 998, 14, 42, 22759, 1206, 63, 46, 2830, 566, 199, 199, 14859, 14, 2573, 63, 509, 63, 1461, 342, 199, 199, 6410, 275, 13172, 14, 362, 63, 6410, 342, 199, 199, 3, 14859, 14, 2379, 342, 199, 199, 692, 440, 7256, 26, 272, 870, 360, 47, 1483, 2263, 358, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1782, 275, 7256, 14, 13012, 1252, 2184, 342, 199, 199, 1361, 360, 20326, 4907, 370, 283, 435, 664, 63, 354, 8, 1782, 430, 199, 199, 68, 18, 67, 63, 719, 275, 841, 708, 709, 199, 5538, 63, 466, 275, 298, 4222, 2, 199, 5538, 63, 354, 275, 298, 991, 66, 411, 5218, 2, 199, 199, 5012, 368, 275, 4885, 66, 411, 63, 2510, 14, 981, 63, 460, 63, 2242, 8, 1782, 12, 366, 18, 67, 63, 719, 12, 7614, 63, 466, 12, 7614, 63, 354, 9, 199, 199, 692, 16642, 368, 365, 488, 26, 272, 870, 360, 6005, 370, 4907, 370, 282, 3336, 358, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 5012, 368, 14, 2724, 63, 929, 342, 199, 199, 2936, 275, 7992, 1252, 1574, 342, 199, 2936, 14, 873, 8, 9350, 1012, 199, 6407, 14, 409, 63, 18452, 8, 4308, 18452, 14, 6600, 351, 8, 2936, 680, 4883, 9, 199, 6407, 14, 1122, 63, 460, 63, 3409, 480, 2902, 26, 4890, 531, 199, 5641, 275, 1233, 14, 23879, 9270, 8, 2936, 9, 199, 199, 3, 16642, 368, 14, 11126, 8, 16, 9, 221, 327, 14882, 7568, 199, 3, 16642, 368, 14, 11126, 8, 17, 9, 221, 327, 14882, 1536, 199, 3, 16642, 368, 14, 1185, 63, 6688, 8, 1165, 9, 221, 327, 4057, 17465, 199, 3, 16642, 368, 14, 1185, 63, 6688, 2801, 1165, 9, 221, 327, 4057, 8552, 199, 3, 16642, 368, 14, 1185, 8, 16, 12, 1400, 9, 221, 327, 7485, 2451, 31, 199, 3, 16642, 368, 14, 1185, 8, 16, 3057, 1400, 9, 221, 327, 7485, 3602, 31, 199, 3, 16642, 368, 14, 14809, 342, 327, 20749, 6818, 199, 3, 16642, 368, 14, 4129, 15957, 8, 16, 9, 199, 3, 16642, 368, 14, 4129, 15957, 8, 25, 9, 199, 3, 13550, 6040, 1338, 26, 199, 3, 260, 446, 378, 520, 3631, 199, 3, 260, 446, 413, 520, 20749, 199, 3, 260, 446, 499, 520, 24410, 199, 3, 260, 446, 650, 520, 11999, 7228, 199, 3, 260, 446, 841, 520, 562, 454, 265, 1377, 199, 3, 260, 446, 959, 520, 641, 68, 5332, 199, 3, 260, 446, 1227, 520, 20749, 11126, 199, 3, 260, 446, 1520, 520, 2249, 442, 411, 941, 608, 199, 3, 260, 446, 1695, 520, 2249, 723, 279, 199, 3, 260, 446, 1749, 520, 5340, 279, 676, 199, 3, 260, 408, 199, 199, 5641, 14, 25850, 342, 199, 5012, 368, 14, 2379, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
samabhi/pstHealth
venv/lib/python2.7/site-packages/django/db/models/sql/query.py
7
93187
""" Create SQL statements for QuerySets. The code in here encapsulates all of the SQL construction so that QuerySets themselves do not have to (and could be backed by things other than SQL databases). The abstraction barrier only works one way: this module has to know all about the internals of models in order to get the information it needs. """ import copy import warnings from collections import Counter, Iterator, Mapping, OrderedDict from itertools import chain, count, product from string import ascii_uppercase from django.core.exceptions import FieldDoesNotExist, FieldError from django.db import DEFAULT_DB_ALIAS, connections from django.db.models.aggregates import Count from django.db.models.constants import LOOKUP_SEP from django.db.models.expressions import Col, Ref from django.db.models.fields.related_lookups import MultiColSource from django.db.models.query_utils import ( Q, PathInfo, check_rel_lookup_compatibility, refs_expression, ) from django.db.models.sql.constants import ( INNER, LOUTER, ORDER_DIR, ORDER_PATTERN, QUERY_TERMS, SINGLE, ) from django.db.models.sql.datastructures import ( BaseTable, Empty, EmptyResultSet, Join, MultiJoin, ) from django.db.models.sql.where import ( AND, OR, ExtraWhere, NothingNode, WhereNode, ) from django.utils import six from django.utils.deprecation import RemovedInDjango110Warning from django.utils.encoding import force_text from django.utils.tree import Node __all__ = ['Query', 'RawQuery'] def get_field_names_from_opts(opts): return set(chain.from_iterable( (f.name, f.attname) if f.concrete else (f.name,) for f in opts.get_fields() )) class RawQuery(object): """ A single raw SQL query """ def __init__(self, sql, using, params=None, context=None): self.params = params or () self.sql = sql self.using = using self.cursor = None # Mirror some properties of a normal query so that # the compiler can be used to process results. self.low_mark, self.high_mark = 0, None # Used for offset/limit self.extra_select = {} self.annotation_select = {} self.context = context or {} def clone(self, using): return RawQuery(self.sql, using, params=self.params, context=self.context.copy()) def get_columns(self): if self.cursor is None: self._execute_query() converter = connections[self.using].introspection.column_name_converter return [converter(column_meta[0]) for column_meta in self.cursor.description] def __iter__(self): # Always execute a new query for a new iterator. # This could be optimized with a cache at the expense of RAM. self._execute_query() if not connections[self.using].features.can_use_chunked_reads: # If the database can't use chunked reads we need to make sure we # evaluate the entire query up front. result = list(self.cursor) else: result = self.cursor return iter(result) def __repr__(self): return "<RawQuery: %s>" % self @property def params_type(self): return dict if isinstance(self.params, Mapping) else tuple def __str__(self): return self.sql % self.params_type(self.params) def _execute_query(self): connection = connections[self.using] # Adapt parameters to the database, as much as possible considering # that the target type isn't known. See #17755. params_type = self.params_type adapter = connection.ops.adapt_unknown_value if params_type is tuple: params = tuple(adapter(val) for val in self.params) elif params_type is dict: params = dict((key, adapter(val)) for key, val in six.iteritems(self.params)) else: raise RuntimeError("Unexpected params type: %s" % params_type) self.cursor = connection.cursor() self.cursor.execute(self.sql, params) class Query(object): """ A single SQL query. """ alias_prefix = 'T' subq_aliases = frozenset([alias_prefix]) query_terms = QUERY_TERMS compiler = 'SQLCompiler' def __init__(self, model, where=WhereNode): self.model = model self.alias_refcount = {} # alias_map is the most important data structure regarding joins. # It's used for recording which joins exist in the query and what # types they are. The key is the alias of the joined table (possibly # the table name) and the value is a Join-like object (see # sql.datastructures.Join for more information). self.alias_map = {} # Sometimes the query contains references to aliases in outer queries (as # a result of split_exclude). Correct alias quoting needs to know these # aliases too. self.external_aliases = set() self.table_map = {} # Maps table names to list of aliases. self.default_cols = True self.default_ordering = True self.standard_ordering = True self.used_aliases = set() self.filter_is_sticky = False # SQL-related attributes # Select and related select clauses are expressions to use in the # SELECT clause of the query. # The select is used for cases where we want to set up the select # clause to contain other than default fields (values(), subqueries...) # Note that annotations go to annotations dictionary. self.select = [] self.tables = [] # Aliases in the order they are created. self.where = where() self.where_class = where # The group_by attribute can have one of the following forms: # - None: no group by at all in the query # - A list of expressions: group by (at least) those expressions. # String refs are also allowed for now. # - True: group by all select fields of the model # See compiler.get_group_by() for details. self.group_by = None self.order_by = [] self.low_mark, self.high_mark = 0, None # Used for offset/limit self.distinct = False self.distinct_fields = [] self.select_for_update = False self.select_for_update_nowait = False self.select_related = False # Arbitrary limit for select_related to prevents infinite recursion. self.max_depth = 5 # Holds the selects defined by a call to values() or values_list() # excluding annotation_select and extra_select. self.values_select = [] # SQL annotation-related attributes # The _annotations will be an OrderedDict when used. Due to the cost # of creating OrderedDict this attribute is created lazily (in # self.annotations property). self._annotations = None # Maps alias -> Annotation Expression self.annotation_select_mask = None self._annotation_select_cache = None # These are for extensions. The contents are more or less appended # verbatim to the appropriate clause. # The _extra attribute is an OrderedDict, lazily created similarly to # .annotations self._extra = None # Maps col_alias -> (col_sql, params). self.extra_select_mask = None self._extra_select_cache = None self.extra_tables = () self.extra_order_by = () # A tuple that is a set of model field names and either True, if these # are the fields to defer, or False if these are the only fields to # load. self.deferred_loading = (set(), True) self.context = {} @property def extra(self): if self._extra is None: self._extra = OrderedDict() return self._extra @property def annotations(self): if self._annotations is None: self._annotations = OrderedDict() return self._annotations @property def aggregates(self): warnings.warn( "The aggregates property is deprecated. Use annotations instead.", RemovedInDjango110Warning, stacklevel=2) return self.annotations def __str__(self): """ Returns the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string). Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time. """ sql, params = self.sql_with_params() return sql % params def sql_with_params(self): """ Returns the query as an SQL string and the parameters that will be substituted into the query. """ return self.get_compiler(DEFAULT_DB_ALIAS).as_sql() def __deepcopy__(self, memo): result = self.clone(memo=memo) memo[id(self)] = result return result def _prepare(self, field): return self def get_compiler(self, using=None, connection=None): if using is None and connection is None: raise ValueError("Need either using or connection") if using: connection = connections[using] return connection.ops.compiler(self.compiler)(self, connection, using) def get_meta(self): """ Returns the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses. """ return self.model._meta def clone(self, klass=None, memo=None, **kwargs): """ Creates a copy of the current instance. The 'kwargs' parameter can be used by clients to update attributes after copying has taken place. """ obj = Empty() obj.__class__ = klass or self.__class__ obj.model = self.model obj.alias_refcount = self.alias_refcount.copy() obj.alias_map = self.alias_map.copy() obj.external_aliases = self.external_aliases.copy() obj.table_map = self.table_map.copy() obj.default_cols = self.default_cols obj.default_ordering = self.default_ordering obj.standard_ordering = self.standard_ordering obj.select = self.select[:] obj.tables = self.tables[:] obj.where = self.where.clone() obj.where_class = self.where_class if self.group_by is None: obj.group_by = None elif self.group_by is True: obj.group_by = True else: obj.group_by = self.group_by[:] obj.order_by = self.order_by[:] obj.low_mark, obj.high_mark = self.low_mark, self.high_mark obj.distinct = self.distinct obj.distinct_fields = self.distinct_fields[:] obj.select_for_update = self.select_for_update obj.select_for_update_nowait = self.select_for_update_nowait obj.select_related = self.select_related obj.values_select = self.values_select[:] obj._annotations = self._annotations.copy() if self._annotations is not None else None if self.annotation_select_mask is None: obj.annotation_select_mask = None else: obj.annotation_select_mask = self.annotation_select_mask.copy() # _annotation_select_cache cannot be copied, as doing so breaks the # (necessary) state in which both annotations and # _annotation_select_cache point to the same underlying objects. # It will get re-populated in the cloned queryset the next time it's # used. obj._annotation_select_cache = None obj.max_depth = self.max_depth obj._extra = self._extra.copy() if self._extra is not None else None if self.extra_select_mask is None: obj.extra_select_mask = None else: obj.extra_select_mask = self.extra_select_mask.copy() if self._extra_select_cache is None: obj._extra_select_cache = None else: obj._extra_select_cache = self._extra_select_cache.copy() obj.extra_tables = self.extra_tables obj.extra_order_by = self.extra_order_by obj.deferred_loading = copy.copy(self.deferred_loading[0]), self.deferred_loading[1] if self.filter_is_sticky and self.used_aliases: obj.used_aliases = self.used_aliases.copy() else: obj.used_aliases = set() obj.filter_is_sticky = False if 'alias_prefix' in self.__dict__: obj.alias_prefix = self.alias_prefix if 'subq_aliases' in self.__dict__: obj.subq_aliases = self.subq_aliases.copy() obj.__dict__.update(kwargs) if hasattr(obj, '_setup_query'): obj._setup_query() obj.context = self.context.copy() return obj def add_context(self, key, value): self.context[key] = value def get_context(self, key, default=None): return self.context.get(key, default) def relabeled_clone(self, change_map): clone = self.clone() clone.change_aliases(change_map) return clone def rewrite_cols(self, annotation, col_cnt): # We must make sure the inner query has the referred columns in it. # If we are aggregating over an annotation, then Django uses Ref() # instances to note this. However, if we are annotating over a column # of a related model, then it might be that column isn't part of the # SELECT clause of the inner query, and we must manually make sure # the column is selected. An example case is: # .aggregate(Sum('author__awards')) # Resolving this expression results in a join to author, but there # is no guarantee the awards column of author is in the select clause # of the query. Thus we must manually add the column to the inner # query. orig_exprs = annotation.get_source_expressions() new_exprs = [] for expr in orig_exprs: if isinstance(expr, Ref): # Its already a Ref to subquery (see resolve_ref() for # details) new_exprs.append(expr) elif isinstance(expr, Col): # Reference to column. Make sure the referenced column # is selected. col_cnt += 1 col_alias = '__col%d' % col_cnt self.annotations[col_alias] = expr self.append_annotation_mask([col_alias]) new_exprs.append(Ref(col_alias, expr)) else: # Some other expression not referencing database values # directly. Its subexpression might contain Cols. new_expr, col_cnt = self.rewrite_cols(expr, col_cnt) new_exprs.append(new_expr) annotation.set_source_expressions(new_exprs) return annotation, col_cnt def get_aggregation(self, using, added_aggregate_names): """ Returns the dictionary with the values of the existing aggregations. """ if not self.annotation_select: return {} has_limit = self.low_mark != 0 or self.high_mark is not None has_existing_annotations = any( annotation for alias, annotation in self.annotations.items() if alias not in added_aggregate_names ) # Decide if we need to use a subquery. # # Existing annotations would cause incorrect results as get_aggregation() # must produce just one result and thus must not use GROUP BY. But we # aren't smart enough to remove the existing annotations from the # query, so those would force us to use GROUP BY. # # If the query has limit or distinct, then those operations must be # done in a subquery so that we are aggregating on the limit and/or # distinct results instead of applying the distinct and limit after the # aggregation. if (isinstance(self.group_by, list) or has_limit or has_existing_annotations or self.distinct): from django.db.models.sql.subqueries import AggregateQuery outer_query = AggregateQuery(self.model) inner_query = self.clone() inner_query.select_for_update = False inner_query.select_related = False if not has_limit and not self.distinct_fields: # Queries with distinct_fields need ordering and when a limit # is applied we must take the slice from the ordered query. # Otherwise no need for ordering. inner_query.clear_ordering(True) if not inner_query.distinct: # If the inner query uses default select and it has some # aggregate annotations, then we must make sure the inner # query is grouped by the main model's primary key. However, # clearing the select clause can alter results if distinct is # used. if inner_query.default_cols and has_existing_annotations: inner_query.group_by = [self.model._meta.pk.get_col(inner_query.get_initial_alias())] inner_query.default_cols = False relabels = {t: 'subquery' for t in inner_query.tables} relabels[None] = 'subquery' # Remove any aggregates marked for reduction from the subquery # and move them to the outer AggregateQuery. col_cnt = 0 for alias, expression in list(inner_query.annotation_select.items()): if expression.is_summary: expression, col_cnt = inner_query.rewrite_cols(expression, col_cnt) outer_query.annotations[alias] = expression.relabeled_clone(relabels) del inner_query.annotations[alias] # Make sure the annotation_select wont use cached results. inner_query.set_annotation_mask(inner_query.annotation_select_mask) if inner_query.select == [] and not inner_query.default_cols and not inner_query.annotation_select_mask: # In case of Model.objects[0:3].count(), there would be no # field selected in the inner query, yet we must use a subquery. # So, make sure at least one field is selected. inner_query.select = [self.model._meta.pk.get_col(inner_query.get_initial_alias())] try: outer_query.add_subquery(inner_query, using) except EmptyResultSet: return { alias: None for alias in outer_query.annotation_select } else: outer_query = self self.select = [] self.default_cols = False self._extra = {} outer_query.clear_ordering(True) outer_query.clear_limits() outer_query.select_for_update = False outer_query.select_related = False compiler = outer_query.get_compiler(using) result = compiler.execute_sql(SINGLE) if result is None: result = [None for q in outer_query.annotation_select.items()] converters = compiler.get_converters(outer_query.annotation_select.values()) result = compiler.apply_converters(result, converters) return { alias: val for (alias, annotation), val in zip(outer_query.annotation_select.items(), result) } def get_count(self, using): """ Performs a COUNT() query using the current filter constraints. """ obj = self.clone() obj.add_annotation(Count('*'), alias='__count', is_summary=True) number = obj.get_aggregation(using, ['__count'])['__count'] if number is None: number = 0 return number def has_filters(self): return self.where def has_results(self, using): q = self.clone() if not q.distinct: if q.group_by is True: q.add_fields((f.attname for f in self.model._meta.concrete_fields), False) q.set_group_by() q.clear_select_clause() q.clear_ordering(True) q.set_limits(high=1) compiler = q.get_compiler(using=using) return compiler.has_results() def combine(self, rhs, connector): """ Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function. The 'connector' parameter describes how to connect filters from the 'rhs' query. """ assert self.model == rhs.model, \ "Cannot combine queries on two different base models." assert self.can_filter(), \ "Cannot combine queries once a slice has been taken." assert self.distinct == rhs.distinct, \ "Cannot combine a unique query with a non-unique query." assert self.distinct_fields == rhs.distinct_fields, \ "Cannot combine queries with different distinct fields." # Work out how to relabel the rhs aliases, if necessary. change_map = {} conjunction = (connector == AND) # Determine which existing joins can be reused. When combining the # query with AND we must recreate all joins for m2m filters. When # combining with OR we can reuse joins. The reason is that in AND # case a single row can't fulfill a condition like: # revrel__col=1 & revrel__col=2 # But, there might be two different related rows matching this # condition. In OR case a single True is enough, so single row is # enough, too. # # Note that we will be creating duplicate joins for non-m2m joins in # the AND case. The results will be correct but this creates too many # joins. This is something that could be fixed later on. reuse = set() if conjunction else set(self.tables) # Base table must be present in the query - this is the same # table on both sides. self.get_initial_alias() joinpromoter = JoinPromoter(connector, 2, False) joinpromoter.add_votes( j for j in self.alias_map if self.alias_map[j].join_type == INNER) rhs_votes = set() # Now, add the joins from rhs query into the new query (skipping base # table). for alias in rhs.tables[1:]: join = rhs.alias_map[alias] # If the left side of the join was already relabeled, use the # updated alias. join = join.relabeled_clone(change_map) new_alias = self.join(join, reuse=reuse) if join.join_type == INNER: rhs_votes.add(new_alias) # We can't reuse the same join again in the query. If we have two # distinct joins for the same connection in rhs query, then the # combined query must have two joins, too. reuse.discard(new_alias) if alias != new_alias: change_map[alias] = new_alias if not rhs.alias_refcount[alias]: # The alias was unused in the rhs query. Unref it so that it # will be unused in the new query, too. We have to add and # unref the alias so that join promotion has information of # the join type for the unused alias. self.unref_alias(new_alias) joinpromoter.add_votes(rhs_votes) joinpromoter.update_join_types(self) # Now relabel a copy of the rhs where-clause and add it to the current # one. w = rhs.where.clone() w.relabel_aliases(change_map) self.where.add(w, connector) # Selection columns and extra extensions are those provided by 'rhs'. self.select = [] for col in rhs.select: self.add_select(col.relabeled_clone(change_map)) if connector == OR: # It would be nice to be able to handle this, but the queries don't # really make sense (or return consistent value sets). Not worth # the extra complexity when you can write a real query instead. if self._extra and rhs._extra: raise ValueError("When merging querysets using 'or', you " "cannot have extra(select=...) on both sides.") self.extra.update(rhs.extra) extra_select_mask = set() if self.extra_select_mask is not None: extra_select_mask.update(self.extra_select_mask) if rhs.extra_select_mask is not None: extra_select_mask.update(rhs.extra_select_mask) if extra_select_mask: self.set_extra_mask(extra_select_mask) self.extra_tables += rhs.extra_tables # Ordering uses the 'rhs' ordering, unless it has none, in which case # the current ordering is used. self.order_by = rhs.order_by[:] if rhs.order_by else self.order_by self.extra_order_by = rhs.extra_order_by or self.extra_order_by def deferred_to_data(self, target, callback): """ Converts the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each model. Models that have all their fields included aren't mentioned in the result, only those that have field restrictions in place. The "target" parameter is the instance that is populated (in place). The "callback" is a function that is called whenever a (model, field) pair need to be added to "target". It accepts three parameters: "target", and the model and list of fields being added for that model. """ field_names, defer = self.deferred_loading if not field_names: return orig_opts = self.get_meta() seen = {} must_include = {orig_opts.concrete_model: {orig_opts.pk}} for field_name in field_names: parts = field_name.split(LOOKUP_SEP) cur_model = self.model._meta.concrete_model opts = orig_opts for name in parts[:-1]: old_model = cur_model source = opts.get_field(name) if is_reverse_o2o(source): cur_model = source.related_model else: cur_model = source.remote_field.model opts = cur_model._meta # Even if we're "just passing through" this model, we must add # both the current model's pk and the related reference field # (if it's not a reverse relation) to the things we select. if not is_reverse_o2o(source): must_include[old_model].add(source) add_to_dict(must_include, cur_model, opts.pk) field = opts.get_field(parts[-1]) is_reverse_object = field.auto_created and not field.concrete model = field.related_model if is_reverse_object else field.model model = model._meta.concrete_model if model == opts.model: model = cur_model if not is_reverse_o2o(field): add_to_dict(seen, model, field) if defer: # We need to load all fields for each model, except those that # appear in "seen" (for all models that appear in "seen"). The only # slight complexity here is handling fields that exist on parent # models. workset = {} for model, values in six.iteritems(seen): for field in model._meta.fields: if field in values: continue m = field.model._meta.concrete_model add_to_dict(workset, m, field) for model, values in six.iteritems(must_include): # If we haven't included a model in workset, we don't add the # corresponding must_include fields for that model, since an # empty set means "include all fields". That's why there's no # "else" branch here. if model in workset: workset[model].update(values) for model, values in six.iteritems(workset): callback(target, model, values) else: for model, values in six.iteritems(must_include): if model in seen: seen[model].update(values) else: # As we've passed through this model, but not explicitly # included any fields, we have to make sure it's mentioned # so that only the "must include" fields are pulled in. seen[model] = values # Now ensure that every model in the inheritance chain is mentioned # in the parent list. Again, it must be mentioned to ensure that # only "must include" fields are pulled in. for model in orig_opts.get_parent_list(): if model not in seen: seen[model] = set() for model, values in six.iteritems(seen): callback(target, model, values) def table_alias(self, table_name, create=False): """ Returns a table alias for the given table_name and whether this is a new alias or not. If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one exists) is reused. """ alias_list = self.table_map.get(table_name) if not create and alias_list: alias = alias_list[0] self.alias_refcount[alias] += 1 return alias, False # Create a new alias for this table. if alias_list: alias = '%s%d' % (self.alias_prefix, len(self.alias_map) + 1) alias_list.append(alias) else: # The first occurrence of a table uses the table name directly. alias = table_name self.table_map[alias] = [alias] self.alias_refcount[alias] = 1 self.tables.append(alias) return alias, True def ref_alias(self, alias): """ Increases the reference count for this alias. """ self.alias_refcount[alias] += 1 def unref_alias(self, alias, amount=1): """ Decreases the reference count for this alias. """ self.alias_refcount[alias] -= amount def promote_joins(self, aliases): """ Promotes recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, the join is only promoted if it is nullable or the parent join is an outer join. The children promotion is done to avoid join chains that contain a LOUTER b INNER c. So, if we have currently a INNER b INNER c and a->b is promoted, then we must also promote b->c automatically, or otherwise the promotion of a->b doesn't actually change anything in the query results. """ aliases = list(aliases) while aliases: alias = aliases.pop(0) if self.alias_map[alias].join_type is None: # This is the base table (first FROM entry) - this table # isn't really joined at all in the query, so we should not # alter its join type. continue # Only the first alias (skipped above) should have None join_type assert self.alias_map[alias].join_type is not None parent_alias = self.alias_map[alias].parent_alias parent_louter = ( parent_alias and self.alias_map[parent_alias].join_type == LOUTER) already_louter = self.alias_map[alias].join_type == LOUTER if ((self.alias_map[alias].nullable or parent_louter) and not already_louter): self.alias_map[alias] = self.alias_map[alias].promote() # Join type of 'alias' changed, so re-examine all aliases that # refer to this one. aliases.extend( join for join in self.alias_map.keys() if (self.alias_map[join].parent_alias == alias and join not in aliases)) def demote_joins(self, aliases): """ Change join type from LOUTER to INNER for all joins in aliases. Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b LOUTER c then we must demote a->b automatically, or otherwise the demotion of b->c doesn't actually change anything in the query results. . """ aliases = list(aliases) while aliases: alias = aliases.pop(0) if self.alias_map[alias].join_type == LOUTER: self.alias_map[alias] = self.alias_map[alias].demote() parent_alias = self.alias_map[alias].parent_alias if self.alias_map[parent_alias].join_type == INNER: aliases.append(parent_alias) def reset_refcounts(self, to_counts): """ This method will reset reference counts for aliases so that they match the value passed in :param to_counts:. """ for alias, cur_refcount in self.alias_refcount.copy().items(): unref_amount = cur_refcount - to_counts.get(alias, 0) self.unref_alias(alias, unref_amount) def change_aliases(self, change_map): """ Changes the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause. """ assert set(change_map.keys()).intersection(set(change_map.values())) == set() def relabel_column(col): if isinstance(col, (list, tuple)): old_alias = col[0] return (change_map.get(old_alias, old_alias), col[1]) else: return col.relabeled_clone(change_map) # 1. Update references in "select" (normal columns plus aliases), # "group by" and "where". self.where.relabel_aliases(change_map) if isinstance(self.group_by, list): self.group_by = [relabel_column(col) for col in self.group_by] self.select = [col.relabeled_clone(change_map) for col in self.select] if self._annotations: self._annotations = OrderedDict( (key, relabel_column(col)) for key, col in self._annotations.items()) # 2. Rename the alias in the internal table/alias datastructures. for old_alias, new_alias in six.iteritems(change_map): if old_alias not in self.alias_map: continue alias_data = self.alias_map[old_alias].relabeled_clone(change_map) self.alias_map[new_alias] = alias_data self.alias_refcount[new_alias] = self.alias_refcount[old_alias] del self.alias_refcount[old_alias] del self.alias_map[old_alias] table_aliases = self.table_map[alias_data.table_name] for pos, alias in enumerate(table_aliases): if alias == old_alias: table_aliases[pos] = new_alias break for pos, alias in enumerate(self.tables): if alias == old_alias: self.tables[pos] = new_alias break self.external_aliases = {change_map.get(alias, alias) for alias in self.external_aliases} def bump_prefix(self, outer_query): """ Changes the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call. """ def prefix_gen(): """ Generates a sequence of characters in alphabetical order: -> 'A', 'B', 'C', ... When the alphabet is finished, the sequence will continue with the Cartesian product: -> 'AA', 'AB', 'AC', ... """ alphabet = ascii_uppercase prefix = chr(ord(self.alias_prefix) + 1) yield prefix for n in count(1): seq = alphabet[alphabet.index(prefix):] if prefix else alphabet for s in product(seq, repeat=n): yield ''.join(s) prefix = None if self.alias_prefix != outer_query.alias_prefix: # No clashes between self and outer query should be possible. return local_recursion_limit = 127 # explicitly avoid infinite loop for pos, prefix in enumerate(prefix_gen()): if prefix not in self.subq_aliases: self.alias_prefix = prefix break if pos > local_recursion_limit: raise RuntimeError( 'Maximum recursion depth exceeded: too many subqueries.' ) self.subq_aliases = self.subq_aliases.union([self.alias_prefix]) outer_query.subq_aliases = outer_query.subq_aliases.union(self.subq_aliases) change_map = OrderedDict() for pos, alias in enumerate(self.tables): new_alias = '%s%d' % (self.alias_prefix, pos) change_map[alias] = new_alias self.tables[pos] = new_alias self.change_aliases(change_map) def get_initial_alias(self): """ Returns the first alias for this query, after increasing its reference count. """ if self.tables: alias = self.tables[0] self.ref_alias(alias) else: alias = self.join(BaseTable(self.get_meta().db_table, None)) return alias def count_active_tables(self): """ Returns the number of tables in this query with a non-zero reference count. Note that after execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method. """ return len([1 for count in self.alias_refcount.values() if count]) def join(self, join, reuse=None): """ Returns an alias for the join in 'connection', either reusing an existing alias for that join or creating a new one. 'connection' is a tuple (lhs, table, join_cols) where 'lhs' is either an existing table alias or a table name. 'join_cols' is a tuple of tuples containing columns to join on ((l_id1, r_id1), (l_id2, r_id2)). The join corresponds to the SQL equivalent of:: lhs.l_id1 = table.r_id1 AND lhs.l_id2 = table.r_id2 The 'reuse' parameter can be either None which means all joins (matching the connection) are reusable, or it can be a set containing the aliases that can be reused. A join is always created as LOUTER if the lhs alias is LOUTER to make sure we do not generate chains like t1 LOUTER t2 INNER t3. All new joins are created as LOUTER if nullable is True. If 'nullable' is True, the join can potentially involve NULL values and is a candidate for promotion (to "left outer") when combining querysets. The 'join_field' is the field we are joining along (if any). """ reuse = [a for a, j in self.alias_map.items() if (reuse is None or a in reuse) and j == join] if reuse: self.ref_alias(reuse[0]) return reuse[0] # No reuse is possible, so we need a new alias. alias, _ = self.table_alias(join.table_name, create=True) if join.join_type: if self.alias_map[join.parent_alias].join_type == LOUTER or join.nullable: join_type = LOUTER else: join_type = INNER join.join_type = join_type join.table_alias = alias self.alias_map[alias] = join return alias def join_parent_model(self, opts, model, alias, seen): """ Makes sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op. The 'alias' is the root alias for starting the join, 'seen' is a dict of model -> alias of existing joins. It must also contain a mapping of None -> some alias. This will be returned in the no-op case. """ if model in seen: return seen[model] chain = opts.get_base_chain(model) if not chain: return alias curr_opts = opts for int_model in chain: if int_model in seen: curr_opts = int_model._meta alias = seen[int_model] continue # Proxy model have elements in base chain # with no parents, assign the new options # object and skip to the next base in that # case if not curr_opts.parents[int_model]: curr_opts = int_model._meta continue link_field = curr_opts.get_ancestor_link(int_model) _, _, _, joins, _ = self.setup_joins( [link_field.name], curr_opts, alias) curr_opts = int_model._meta alias = seen[int_model] = joins[-1] return alias or seen[None] def add_aggregate(self, aggregate, model, alias, is_summary): warnings.warn( "add_aggregate() is deprecated. Use add_annotation() instead.", RemovedInDjango110Warning, stacklevel=2) self.add_annotation(aggregate, alias, is_summary) def add_annotation(self, annotation, alias, is_summary=False): """ Adds a single annotation expression to the Query """ annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None, summarize=is_summary) self.append_annotation_mask([alias]) self.annotations[alias] = annotation def prepare_lookup_value(self, value, lookups, can_reuse, allow_joins=True): # Default lookup if none given is exact. used_joins = [] if len(lookups) == 0: lookups = ['exact'] # Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all # uses of None as a query value. if value is None: if lookups[-1] not in ('exact', 'iexact'): raise ValueError("Cannot use None as a query value") lookups[-1] = 'isnull' value = True elif hasattr(value, 'resolve_expression'): pre_joins = self.alias_refcount.copy() value = value.resolve_expression(self, reuse=can_reuse, allow_joins=allow_joins) used_joins = [k for k, v in self.alias_refcount.items() if v > pre_joins.get(k, 0)] # Subqueries need to use a different set of aliases than the # outer query. Call bump_prefix to change aliases of the inner # query (the value). if hasattr(value, 'query') and hasattr(value.query, 'bump_prefix'): value = value._clone() value.query.bump_prefix(self) if hasattr(value, 'bump_prefix'): value = value.clone() value.bump_prefix(self) # For Oracle '' is equivalent to null. The check needs to be done # at this stage because join promotion can't be done at compiler # stage. Using DEFAULT_DB_ALIAS isn't nice, but it is the best we # can do here. Similar thing is done in is_nullable(), too. if (connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and lookups[-1] == 'exact' and value == ''): value = True lookups[-1] = 'isnull' return value, lookups, used_joins def solve_lookup_type(self, lookup): """ Solve the lookup type from the lookup (eg: 'foobar__id__icontains') """ lookup_splitted = lookup.split(LOOKUP_SEP) if self._annotations: expression, expression_lookups = refs_expression(lookup_splitted, self.annotations) if expression: return expression_lookups, (), expression _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta()) field_parts = lookup_splitted[0:len(lookup_splitted) - len(lookup_parts)] if len(lookup_parts) == 0: lookup_parts = ['exact'] elif len(lookup_parts) > 1: if not field_parts: raise FieldError( 'Invalid lookup "%s" for model %s".' % (lookup, self.get_meta().model.__name__)) return lookup_parts, field_parts, False def check_query_object_type(self, value, opts, field): """ Checks whether the object passed while querying is of the correct type. If not, it raises a ValueError specifying the wrong object. """ if hasattr(value, '_meta'): if not check_rel_lookup_compatibility(value._meta.model, opts, field): raise ValueError( 'Cannot query "%s": Must be "%s" instance.' % (value, opts.object_name)) def check_related_objects(self, field, value, opts): """ Checks the type of object passed to query relations. """ if field.is_relation: # QuerySets implement is_compatible_query_object_type() to # determine compatibility with the given field. if hasattr(value, 'is_compatible_query_object_type'): if not value.is_compatible_query_object_type(opts, field): raise ValueError( 'Cannot use QuerySet for "%s": Use a QuerySet for "%s".' % (value.model._meta.model_name, opts.object_name) ) elif hasattr(value, '_meta'): self.check_query_object_type(value, opts, field) elif hasattr(value, '__iter__'): for v in value: self.check_query_object_type(v, opts, field) def build_lookup(self, lookups, lhs, rhs): """ Tries to extract transforms and lookup from given lhs. The lhs value is something that works like SQLExpression. The rhs value is what the lookup is going to compare against. The lookups is a list of names to extract using get_lookup() and get_transform(). """ lookups = lookups[:] while lookups: name = lookups[0] # If there is just one part left, try first get_lookup() so # that if the lhs supports both transform and lookup for the # name, then lookup will be picked. if len(lookups) == 1: final_lookup = lhs.get_lookup(name) if not final_lookup: # We didn't find a lookup. We are going to interpret # the name as transform, and do an Exact lookup against # it. lhs = self.try_transform(lhs, name, lookups) final_lookup = lhs.get_lookup('exact') return final_lookup(lhs, rhs) lhs = self.try_transform(lhs, name, lookups) lookups = lookups[1:] def try_transform(self, lhs, name, rest_of_lookups): """ Helper method for build_lookup. Tries to fetch and initialize a transform for name parameter from lhs. """ transform_class = lhs.get_transform(name) if transform_class: return transform_class(lhs) else: raise FieldError( "Unsupported lookup '%s' for %s or join on the field not " "permitted." % (name, lhs.output_field.__class__.__name__)) def build_filter(self, filter_expr, branch_negated=False, current_negated=False, can_reuse=None, connector=AND, allow_joins=True, split_subq=True): """ Builds a WhereNode for a single filter clause, but doesn't add it to this Query. Query.add_q() will then add this filter to the where Node. The 'branch_negated' tells us if the current branch contains any negations. This will be used to determine if subqueries are needed. The 'current_negated' is used to determine if the current filter is negated or not and this will be used to determine if IS NULL filtering is needed. The difference between current_netageted and branch_negated is that branch_negated is set on first negation, but current_negated is flipped for each negation. Note that add_filter will not do any negating itself, that is done upper in the code by add_q(). The 'can_reuse' is a set of reusable joins for multijoins. The method will create a filter clause that can be added to the current query. However, if the filter isn't added to the query then the caller is responsible for unreffing the joins used. """ if isinstance(filter_expr, dict): raise FieldError("Cannot parse keyword query as dict") arg, value = filter_expr if not arg: raise FieldError("Cannot parse keyword query %r" % arg) lookups, parts, reffed_expression = self.solve_lookup_type(arg) if not allow_joins and len(parts) > 1: raise FieldError("Joined field references are not permitted in this query") # Work out the lookup type and remove it from the end of 'parts', # if necessary. value, lookups, used_joins = self.prepare_lookup_value(value, lookups, can_reuse, allow_joins) clause = self.where_class() if reffed_expression: condition = self.build_lookup(lookups, reffed_expression, value) clause.add(condition, AND) return clause, [] opts = self.get_meta() alias = self.get_initial_alias() allow_many = not branch_negated or not split_subq try: field, sources, opts, join_list, path = self.setup_joins( parts, opts, alias, can_reuse=can_reuse, allow_many=allow_many) # Prevent iterator from being consumed by check_related_objects() if isinstance(value, Iterator): value = list(value) self.check_related_objects(field, value, opts) # split_exclude() needs to know which joins were generated for the # lookup parts self._lookup_joins = join_list except MultiJoin as e: return self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]), can_reuse, e.names_with_path) if can_reuse is not None: can_reuse.update(join_list) used_joins = set(used_joins).union(set(join_list)) targets, alias, join_list = self.trim_joins(sources, join_list, path) if field.is_relation: # No support for transforms for relational fields num_lookups = len(lookups) if num_lookups > 1: raise FieldError('Related Field got invalid lookup: {}'.format(lookups[0])) assert num_lookups > 0 # Likely a bug in Django if this fails. lookup_class = field.get_lookup(lookups[0]) if len(targets) == 1: lhs = targets[0].get_col(alias, field) else: lhs = MultiColSource(alias, targets, sources, field) condition = lookup_class(lhs, value) lookup_type = lookup_class.lookup_name else: col = targets[0].get_col(alias, field) condition = self.build_lookup(lookups, col, value) lookup_type = condition.lookup_name clause.add(condition, AND) require_outer = lookup_type == 'isnull' and value is True and not current_negated if current_negated and (lookup_type != 'isnull' or value is False): require_outer = True if (lookup_type != 'isnull' and ( self.is_nullable(targets[0]) or self.alias_map[join_list[-1]].join_type == LOUTER)): # The condition added here will be SQL like this: # NOT (col IS NOT NULL), where the first NOT is added in # upper layers of code. The reason for addition is that if col # is null, then col != someval will result in SQL "unknown" # which isn't the same as in Python. The Python None handling # is wanted, and it can be gotten by # (col IS NULL OR col != someval) # <=> # NOT (col IS NOT NULL AND col = someval). lookup_class = targets[0].get_lookup('isnull') clause.add(lookup_class(targets[0].get_col(alias, sources[0]), False), AND) return clause, used_joins if not require_outer else () def add_filter(self, filter_clause): self.add_q(Q(**{filter_clause[0]: filter_clause[1]})) def add_q(self, q_object): """ A preprocessor for the internal _add_q(). Responsible for doing final join promotion. """ # For join promotion this case is doing an AND for the added q_object # and existing conditions. So, any existing inner join forces the join # type to remain inner. Existing outer joins can however be demoted. # (Consider case where rel_a is LOUTER and rel_a__col=1 is added - if # rel_a doesn't produce any rows, then the whole condition must fail. # So, demotion is OK. existing_inner = set( (a for a in self.alias_map if self.alias_map[a].join_type == INNER)) clause, _ = self._add_q(q_object, self.used_aliases) if clause: self.where.add(clause, AND) self.demote_joins(existing_inner) def _add_q(self, q_object, used_aliases, branch_negated=False, current_negated=False, allow_joins=True, split_subq=True): """ Adds a Q-object to the current filter. """ connector = q_object.connector current_negated = current_negated ^ q_object.negated branch_negated = branch_negated or q_object.negated target_clause = self.where_class(connector=connector, negated=q_object.negated) joinpromoter = JoinPromoter(q_object.connector, len(q_object.children), current_negated) for child in q_object.children: if isinstance(child, Node): child_clause, needed_inner = self._add_q( child, used_aliases, branch_negated, current_negated, allow_joins, split_subq) joinpromoter.add_votes(needed_inner) else: child_clause, needed_inner = self.build_filter( child, can_reuse=used_aliases, branch_negated=branch_negated, current_negated=current_negated, connector=connector, allow_joins=allow_joins, split_subq=split_subq, ) joinpromoter.add_votes(needed_inner) if child_clause: target_clause.add(child_clause, connector) needed_inner = joinpromoter.update_join_types(self) return target_clause, needed_inner def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False): """ Walks the list of names and turns them into PathInfo tuples. Note that a single name in 'names' can generate multiple PathInfos (m2m for example). 'names' is the path of names to travel, 'opts' is the model Options we start the name resolving from, 'allow_many' is as for setup_joins(). If fail_on_missing is set to True, then a name that can't be resolved will generate a FieldError. Returns a list of PathInfo tuples. In addition returns the final field (the last used join field), and target (which is a field guaranteed to contain the same value as the final field). Finally, the method returns those names that weren't found (which are likely transforms and the final lookup). """ path, names_with_path = [], [] for pos, name in enumerate(names): cur_names_with_path = (name, []) if name == 'pk': name = opts.pk.name field = None try: field = opts.get_field(name) except FieldDoesNotExist: if name in self.annotation_select: field = self.annotation_select[name].output_field if field is not None: # Fields that contain one-to-many relations with a generic # model (like a GenericForeignKey) cannot generate reverse # relations and therefore cannot be used for reverse querying. if field.is_relation and not field.related_model: raise FieldError( "Field %r does not generate an automatic reverse " "relation and therefore cannot be used for reverse " "querying. If it is a GenericForeignKey, consider " "adding a GenericRelation." % name ) try: model = field.model._meta.concrete_model except AttributeError: model = None else: # We didn't find the current field, so move position back # one step. pos -= 1 if pos == -1 or fail_on_missing: field_names = list(get_field_names_from_opts(opts)) available = sorted(field_names + list(self.annotation_select)) raise FieldError("Cannot resolve keyword %r into field. " "Choices are: %s" % (name, ", ".join(available))) break # Check if we need any joins for concrete inheritance cases (the # field lives in parent, but we are currently in one of its # children) if model is not opts.model: # The field lives on a base class of the current model. # Skip the chain of proxy to the concrete proxied model proxied_model = opts.concrete_model for int_model in opts.get_base_chain(model): if int_model is proxied_model: opts = int_model._meta else: final_field = opts.parents[int_model] targets = (final_field.remote_field.get_related_field(),) opts = int_model._meta path.append(PathInfo(final_field.model._meta, opts, targets, final_field, False, True)) cur_names_with_path[1].append( PathInfo(final_field.model._meta, opts, targets, final_field, False, True) ) if hasattr(field, 'get_path_info'): pathinfos = field.get_path_info() if not allow_many: for inner_pos, p in enumerate(pathinfos): if p.m2m: cur_names_with_path[1].extend(pathinfos[0:inner_pos + 1]) names_with_path.append(cur_names_with_path) raise MultiJoin(pos + 1, names_with_path) last = pathinfos[-1] path.extend(pathinfos) final_field = last.join_field opts = last.to_opts targets = last.target_fields cur_names_with_path[1].extend(pathinfos) names_with_path.append(cur_names_with_path) else: # Local non-relational field. final_field = field targets = (field,) if fail_on_missing and pos + 1 != len(names): raise FieldError( "Cannot resolve keyword %r into field. Join on '%s'" " not permitted." % (names[pos + 1], name)) break return path, final_field, targets, names[pos + 1:] def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True): """ Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from. The 'can_reuse' defines the reverse foreign key joins we can reuse. It can be None in which case all joins are reusable or a set of aliases that can be reused. Note that non-reverse foreign keys are always reusable when using setup_joins(). If 'allow_many' is False, then any reverse foreign key seen will generate a MultiJoin exception. Returns the final field involved in the joins, the target field (used for any 'where' constraint), the final 'opts' value, the joins and the field path travelled to generate the joins. The target field is the field containing the concrete value. Final field can be something different, for example foreign key pointing to that value. Final field is needed for example in some value conversions (convert 'obj' in fk__id=obj to pk val using the foreign key field for example). """ joins = [alias] # First, generate the path for the names path, final_field, targets, rest = self.names_to_path( names, opts, allow_many, fail_on_missing=True) # Then, add the path to the query's joins. Note that we can't trim # joins at this stage - we will need the information about join type # of the trimmed joins. for join in path: opts = join.to_opts if join.direct: nullable = self.is_nullable(join.join_field) else: nullable = True connection = Join(opts.db_table, alias, None, INNER, join.join_field, nullable) reuse = can_reuse if join.m2m else None alias = self.join(connection, reuse=reuse) joins.append(alias) return final_field, targets, opts, joins, path def trim_joins(self, targets, joins, path): """ The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins. Returns the final target field and table alias and the new active joins. We will always trim any direct join if we have the target column available already in the previous table. Reverse joins can't be trimmed as we don't know if there is anything on the other side of the join. """ joins = joins[:] for pos, info in enumerate(reversed(path)): if len(joins) == 1 or not info.direct: break join_targets = set(t.column for t in info.join_field.foreign_related_fields) cur_targets = set(t.column for t in targets) if not cur_targets.issubset(join_targets): break targets = tuple(r[0] for r in info.join_field.related_fields if r[1].column in cur_targets) self.unref_alias(joins.pop()) return targets, joins[-1], joins def resolve_ref(self, name, allow_joins=True, reuse=None, summarize=False): if not allow_joins and LOOKUP_SEP in name: raise FieldError("Joined field references are not permitted in this query") if name in self.annotations: if summarize: # Summarize currently means we are doing an aggregate() query # which is executed as a wrapped subquery if any of the # aggregate() elements reference an existing annotation. In # that case we need to return a Ref to the subquery's annotation. return Ref(name, self.annotation_select[name]) else: return self.annotation_select[name] else: field_list = name.split(LOOKUP_SEP) field, sources, opts, join_list, path = self.setup_joins( field_list, self.get_meta(), self.get_initial_alias(), reuse) targets, _, join_list = self.trim_joins(sources, join_list, path) if len(targets) > 1: raise FieldError("Referencing multicolumn fields with F() objects " "isn't supported") if reuse is not None: reuse.update(join_list) col = targets[0].get_col(join_list[-1], sources[0]) return col def split_exclude(self, filter_expr, prefix, can_reuse, names_with_path): """ When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field. As an example we could have original filter ~Q(child__name='foo'). We would get here with filter_expr = child__name, prefix = child and can_reuse is a set of joins usable for filters in the original query. We will turn this into equivalent of: WHERE NOT (pk IN (SELECT parent_id FROM thetable WHERE name = 'foo' AND parent_id IS NOT NULL)) It might be worth it to consider using WHERE NOT EXISTS as that has saner null handling, and is easier for the backend's optimizer to handle. """ # Generate the inner query. query = Query(self.model) query.add_filter(filter_expr) query.clear_ordering(True) # Try to have as simple as possible subquery -> trim leading joins from # the subquery. trimmed_prefix, contains_louter = query.trim_start(names_with_path) # Add extra check to make sure the selected field will not be null # since we are adding an IN <subquery> clause. This prevents the # database from tripping over IN (...,NULL,...) selects and returning # nothing col = query.select[0] select_field = col.target alias = col.alias if self.is_nullable(select_field): lookup_class = select_field.get_lookup('isnull') lookup = lookup_class(select_field.get_col(alias), False) query.where.add(lookup, AND) if alias in can_reuse: pk = select_field.model._meta.pk # Need to add a restriction so that outer query's filters are in effect for # the subquery, too. query.bump_prefix(self) lookup_class = select_field.get_lookup('exact') # Note that the query.select[0].alias is different from alias # due to bump_prefix above. lookup = lookup_class(pk.get_col(query.select[0].alias), pk.get_col(alias)) query.where.add(lookup, AND) query.external_aliases.add(alias) condition, needed_inner = self.build_filter( ('%s__in' % trimmed_prefix, query), current_negated=True, branch_negated=True, can_reuse=can_reuse) if contains_louter: or_null_condition, _ = self.build_filter( ('%s__isnull' % trimmed_prefix, True), current_negated=True, branch_negated=True, can_reuse=can_reuse) condition.add(or_null_condition, OR) # Note that the end result will be: # (outercol NOT IN innerq AND outercol IS NOT NULL) OR outercol IS NULL. # This might look crazy but due to how IN works, this seems to be # correct. If the IS NOT NULL check is removed then outercol NOT # IN will return UNKNOWN. If the IS NULL check is removed, then if # outercol IS NULL we will not match the row. return condition, needed_inner def set_empty(self): self.where.add(NothingNode(), AND) def is_empty(self): return any(isinstance(c, NothingNode) for c in self.where.children) def set_limits(self, low=None, high=None): """ Adjusts the limits on the rows retrieved. We use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, they are converted to the appropriate offset and limit values. Any limits passed in here are applied relative to the existing constraints. So low is added to the current low value and both will be clamped to any existing high value. """ if high is not None: if self.high_mark is not None: self.high_mark = min(self.high_mark, self.low_mark + high) else: self.high_mark = self.low_mark + high if low is not None: if self.high_mark is not None: self.low_mark = min(self.high_mark, self.low_mark + low) else: self.low_mark = self.low_mark + low if self.low_mark == self.high_mark: self.set_empty() def clear_limits(self): """ Clears any existing limits. """ self.low_mark, self.high_mark = 0, None def can_filter(self): """ Returns True if adding filters to this instance is still possible. Typically, this means no limits or offsets have been put on the results. """ return not self.low_mark and self.high_mark is None def clear_select_clause(self): """ Removes all fields from SELECT clause. """ self.select = [] self.default_cols = False self.select_related = False self.set_extra_mask(()) self.set_annotation_mask(()) def clear_select_fields(self): """ Clears the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns. """ self.select = [] self.values_select = [] def add_select(self, col): self.default_cols = False self.select.append(col) def set_select(self, cols): self.default_cols = False self.select = cols def add_distinct_fields(self, *field_names): """ Adds and resolves the given fields to the query's "distinct on" clause. """ self.distinct_fields = field_names self.distinct = True def add_fields(self, field_names, allow_m2m=True): """ Adds the given (model) fields to the select set. The field names are added in the order specified. """ alias = self.get_initial_alias() opts = self.get_meta() try: for name in field_names: # Join promotion note - we must not remove any rows here, so # if there is no existing joins, use outer join. _, targets, _, joins, path = self.setup_joins( name.split(LOOKUP_SEP), opts, alias, allow_many=allow_m2m) targets, final_alias, joins = self.trim_joins(targets, joins, path) for target in targets: self.add_select(target.get_col(final_alias)) except MultiJoin: raise FieldError("Invalid field name: '%s'" % name) except FieldError: if LOOKUP_SEP in name: # For lookups spanning over relationships, show the error # from the model on which the lookup failed. raise else: names = sorted(list(get_field_names_from_opts(opts)) + list(self.extra) + list(self.annotation_select)) raise FieldError("Cannot resolve keyword %r into field. " "Choices are: %s" % (name, ", ".join(names))) def add_ordering(self, *ordering): """ Adds items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions. If 'ordering' is empty, all ordering is cleared from the query. """ errors = [] for item in ordering: if not hasattr(item, 'resolve_expression') and not ORDER_PATTERN.match(item): errors.append(item) if getattr(item, 'contains_aggregate', False): raise FieldError( 'Using an aggregate in order_by() without also including ' 'it in annotate() is not allowed: %s' % item ) if errors: raise FieldError('Invalid order_by arguments: %s' % errors) if ordering: self.order_by.extend(ordering) else: self.default_ordering = False def clear_ordering(self, force_empty): """ Removes any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default). """ self.order_by = [] self.extra_order_by = () if force_empty: self.default_ordering = False def set_group_by(self): """ Expands the GROUP BY clause required by the query. This will usually be the set of all non-aggregate fields in the return data. If the database backend supports grouping by the primary key, and the query would be equivalent, the optimization will be made automatically. """ self.group_by = [] for col in self.select: self.group_by.append(col) if self.annotation_select: for alias, annotation in six.iteritems(self.annotation_select): for col in annotation.get_group_by_cols(): self.group_by.append(col) def add_select_related(self, fields): """ Sets up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True). """ if isinstance(self.select_related, bool): field_dict = {} else: field_dict = self.select_related for field in fields: d = field_dict for part in field.split(LOOKUP_SEP): d = d.setdefault(part, {}) self.select_related = field_dict def add_extra(self, select, select_params, where, params, tables, order_by): """ Adds data to the various extra_* attributes for user-created additions to the query. """ if select: # We need to pair any placeholder markers in the 'select' # dictionary with their parameters in 'select_params' so that # subsequent updates to the select dictionary also adjust the # parameters appropriately. select_pairs = OrderedDict() if select_params: param_iter = iter(select_params) else: param_iter = iter([]) for name, entry in select.items(): entry = force_text(entry) entry_params = [] pos = entry.find("%s") while pos != -1: if pos == 0 or entry[pos - 1] != '%': entry_params.append(next(param_iter)) pos = entry.find("%s", pos + 2) select_pairs[name] = (entry, entry_params) # This is order preserving, since self.extra_select is an OrderedDict. self.extra.update(select_pairs) if where or params: self.where.add(ExtraWhere(where, params), AND) if tables: self.extra_tables += tuple(tables) if order_by: self.extra_order_by = order_by def clear_deferred_loading(self): """ Remove any fields from the deferred loading set. """ self.deferred_loading = (set(), True) def add_deferred_loading(self, field_names): """ Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. The new field names are added to any existing field names that are deferred (or removed from any existing field names that are marked as the only ones for immediate loading). """ # Fields on related models are stored in the literal double-underscore # format, so that we can use a set datastructure. We do the foo__bar # splitting and handling when computing the SQL column names (as part of # get_columns()). existing, defer = self.deferred_loading if defer: # Add to existing deferred names. self.deferred_loading = existing.union(field_names), True else: # Remove names from the set of any existing "immediate load" names. self.deferred_loading = existing.difference(field_names), False def add_immediate_loading(self, field_names): """ Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, those names are removed from the new field_names before storing the new names for immediate loading. (That is, immediate loading overrides any existing immediate values, but respects existing deferrals.) """ existing, defer = self.deferred_loading field_names = set(field_names) if 'pk' in field_names: field_names.remove('pk') field_names.add(self.get_meta().pk.name) if defer: # Remove any existing deferred names from the current set before # setting the new names. self.deferred_loading = field_names.difference(existing), False else: # Replace any existing "immediate load" field names. self.deferred_loading = field_names, False def get_loaded_field_names(self): """ If any fields are marked to be deferred, returns a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred. If no fields are marked for deferral, returns an empty dictionary. """ # We cache this because we call this function multiple times # (compiler.fill_related_selections, query.iterator) try: return self._loaded_field_names_cache except AttributeError: collection = {} self.deferred_to_data(collection, self.get_loaded_field_names_cb) self._loaded_field_names_cache = collection return collection def get_loaded_field_names_cb(self, target, model, fields): """ Callback used by get_deferred_field_names(). """ target[model] = {f.attname for f in fields} def set_aggregate_mask(self, names): warnings.warn( "set_aggregate_mask() is deprecated. Use set_annotation_mask() instead.", RemovedInDjango110Warning, stacklevel=2) self.set_annotation_mask(names) def set_annotation_mask(self, names): "Set the mask of annotations that will actually be returned by the SELECT" if names is None: self.annotation_select_mask = None else: self.annotation_select_mask = set(names) self._annotation_select_cache = None def append_aggregate_mask(self, names): warnings.warn( "append_aggregate_mask() is deprecated. Use append_annotation_mask() instead.", RemovedInDjango110Warning, stacklevel=2) self.append_annotation_mask(names) def append_annotation_mask(self, names): if self.annotation_select_mask is not None: self.set_annotation_mask(set(names).union(self.annotation_select_mask)) def set_extra_mask(self, names): """ Set the mask of extra select items that will be returned by SELECT, we don't actually remove them from the Query since they might be used later """ if names is None: self.extra_select_mask = None else: self.extra_select_mask = set(names) self._extra_select_cache = None @property def annotation_select(self): """The OrderedDict of aggregate columns that are not masked, and should be used in the SELECT clause. This result is cached for optimization purposes. """ if self._annotation_select_cache is not None: return self._annotation_select_cache elif not self._annotations: return {} elif self.annotation_select_mask is not None: self._annotation_select_cache = OrderedDict( (k, v) for k, v in self.annotations.items() if k in self.annotation_select_mask ) return self._annotation_select_cache else: return self.annotations @property def aggregate_select(self): warnings.warn( "aggregate_select() is deprecated. Use annotation_select() instead.", RemovedInDjango110Warning, stacklevel=2) return self.annotation_select @property def extra_select(self): if self._extra_select_cache is not None: return self._extra_select_cache if not self._extra: return {} elif self.extra_select_mask is not None: self._extra_select_cache = OrderedDict( (k, v) for k, v in self.extra.items() if k in self.extra_select_mask ) return self._extra_select_cache else: return self.extra def trim_start(self, names_with_path): """ Trims joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins. Also sets the select column so the start matches the join. This method is meant to be used for generating the subquery joins & cols in split_exclude(). Returns a lookup usable for doing outerq.filter(lookup=self). Returns also if the joins in the prefix contain a LEFT OUTER join. _""" all_paths = [] for _, paths in names_with_path: all_paths.extend(paths) contains_louter = False # Trim and operate only on tables that were generated for # the lookup part of the query. That is, avoid trimming # joins generated for F() expressions. lookup_tables = [t for t in self.tables if t in self._lookup_joins or t == self.tables[0]] for trimmed_paths, path in enumerate(all_paths): if path.m2m: break if self.alias_map[lookup_tables[trimmed_paths + 1]].join_type == LOUTER: contains_louter = True alias = lookup_tables[trimmed_paths] self.unref_alias(alias) # The path.join_field is a Rel, lets get the other side's field join_field = path.join_field.field # Build the filter prefix. paths_in_prefix = trimmed_paths trimmed_prefix = [] for name, path in names_with_path: if paths_in_prefix - len(path) < 0: break trimmed_prefix.append(name) paths_in_prefix -= len(path) trimmed_prefix.append( join_field.foreign_related_fields[0].name) trimmed_prefix = LOOKUP_SEP.join(trimmed_prefix) # Lets still see if we can trim the first join from the inner query # (that is, self). We can't do this for LEFT JOINs because we would # miss those rows that have nothing on the outer side. if self.alias_map[lookup_tables[trimmed_paths + 1]].join_type != LOUTER: select_fields = [r[0] for r in join_field.related_fields] select_alias = lookup_tables[trimmed_paths + 1] self.unref_alias(lookup_tables[trimmed_paths]) extra_restriction = join_field.get_extra_restriction( self.where_class, None, lookup_tables[trimmed_paths + 1]) if extra_restriction: self.where.add(extra_restriction, AND) else: # TODO: It might be possible to trim more joins from the start of the # inner query if it happens to have a longer join chain containing the # values in select_fields. Lets punt this one for now. select_fields = [r[1] for r in join_field.related_fields] select_alias = lookup_tables[trimmed_paths] # The found starting point is likely a Join instead of a BaseTable reference. # But the first entry in the query's FROM clause must not be a JOIN. for table in self.tables: if self.alias_refcount[table] > 0: self.alias_map[table] = BaseTable(self.alias_map[table].table_name, table) break self.set_select([f.get_col(select_alias) for f in select_fields]) return trimmed_prefix, contains_louter def is_nullable(self, field): """ A helper to check if the given field should be treated as nullable. Some backends treat '' as null and Django treats such fields as nullable for those backends. In such situations field.null can be False even if we should treat the field as nullable. """ # We need to use DEFAULT_DB_ALIAS here, as QuerySet does not have # (nor should it have) knowledge of which connection is going to be # used. The proper fix would be to defer all decisions where # is_nullable() is needed to the compiler stage, but that is not easy # to do currently. if ((connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls) and field.empty_strings_allowed): return True else: return field.null def get_order_dir(field, default='ASC'): """ Returns the field name and direction for an order specification. For example, '-foo' is returned as ('foo', 'DESC'). The 'default' param is used to indicate which way no prefix (or a '+' prefix) should sort. The '-' prefix always sorts the opposite way. """ dirn = ORDER_DIR[default] if field[0] == '-': return field[1:], dirn[1] return field, dirn[0] def add_to_dict(data, key, value): """ A helper function to add "value" to the set of values for "key", whether or not "key" already exists. """ if key in data: data[key].add(value) else: data[key] = {value} def is_reverse_o2o(field): """ A little helper to check if the given field is reverse-o2o. The field is expected to be some sort of relation field or related object. """ return field.is_relation and field.one_to_one and not field.concrete class JoinPromoter(object): """ A class to abstract away join promotion problems for complex filter conditions. """ def __init__(self, connector, num_children, negated): self.connector = connector self.negated = negated if self.negated: if connector == AND: self.effective_connector = OR else: self.effective_connector = AND else: self.effective_connector = self.connector self.num_children = num_children # Maps of table alias to how many times it is seen as required for # inner and/or outer joins. self.votes = Counter() def add_votes(self, votes): """ Add single vote per item to self.votes. Parameter can be any iterable. """ self.votes.update(votes) def update_join_types(self, query): """ Change join types so that the generated query is as efficient as possible, but still correct. So, change as many joins as possible to INNER, but don't make OUTER joins INNER if that could remove results from the query. """ to_promote = set() to_demote = set() # The effective_connector is used so that NOT (a AND b) is treated # similarly to (a OR b) for join promotion. for table, votes in self.votes.items(): # We must use outer joins in OR case when the join isn't contained # in all of the joins. Otherwise the INNER JOIN itself could remove # valid results. Consider the case where a model with rel_a and # rel_b relations is queried with rel_a__col=1 | rel_b__col=2. Now, # if rel_a join doesn't produce any results is null (for example # reverse foreign key or null value in direct foreign key), and # there is a matching row in rel_b with col=2, then an INNER join # to rel_a would remove a valid match from the query. So, we need # to promote any existing INNER to LOUTER (it is possible this # promotion in turn will be demoted later on). if self.effective_connector == 'OR' and votes < self.num_children: to_promote.add(table) # If connector is AND and there is a filter that can match only # when there is a joinable row, then use INNER. For example, in # rel_a__col=1 & rel_b__col=2, if either of the rels produce NULL # as join output, then the col=1 or col=2 can't match (as # NULL=anything is always false). # For the OR case, if all children voted for a join to be inner, # then we can use INNER for the join. For example: # (rel_a__col__icontains=Alex | rel_a__col__icontains=Russell) # then if rel_a doesn't produce any rows, the whole condition # can't match. Hence we can safely use INNER join. if self.effective_connector == 'AND' or ( self.effective_connector == 'OR' and votes == self.num_children): to_demote.add(table) # Finally, what happens in cases where we have: # (rel_a__col=1|rel_b__col=2) & rel_a__col__gte=0 # Now, we first generate the OR clause, and promote joins for it # in the first if branch above. Both rel_a and rel_b are promoted # to LOUTER joins. After that we do the AND case. The OR case # voted no inner joins but the rel_a__col__gte=0 votes inner join # for rel_a. We demote it back to INNER join (in AND case a single # vote is enough). The demotion is OK, if rel_a doesn't produce # rows, then the rel_a__col__gte=0 clause can't be true, and thus # the whole clause must be false. So, it is safe to use INNER # join. # Note that in this example we could just as well have the __gte # clause and the OR clause swapped. Or we could replace the __gte # clause with an OR clause containing rel_a__col=1|rel_a__col=2, # and again we could safely demote to INNER. query.promote_joins(to_promote) query.demote_joins(to_demote) return to_demote
mit
[ 624, 199, 2499, 5385, 9834, 367, 8133, 9899, 14, 199, 199, 1918, 1233, 315, 2348, 22667, 15409, 1006, 402, 314, 5385, 14538, 880, 626, 8133, 9899, 199, 1589, 77, 16887, 886, 440, 1172, 370, 334, 460, 4293, 506, 1771, 379, 701, 7645, 1163, 2419, 5385, 199, 17439, 680, 710, 2236, 29639, 29741, 1454, 5419, 1373, 4340, 26, 642, 859, 965, 370, 5715, 199, 452, 3595, 314, 5007, 83, 402, 1709, 315, 1865, 370, 664, 314, 2556, 652, 4839, 14, 199, 624, 199, 646, 1331, 199, 646, 3598, 199, 504, 5055, 492, 14427, 12, 25769, 12, 12340, 12, 8773, 199, 504, 7975, 492, 6036, 12, 2338, 12, 3336, 199, 504, 1059, 492, 13294, 63, 26831, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 12, 27691, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 6947, 199, 504, 1639, 14, 697, 14, 992, 14, 21622, 492, 14826, 199, 504, 1639, 14, 697, 14, 992, 14, 5559, 492, 3412, 3593, 2160, 63, 20848, 199, 504, 1639, 14, 697, 14, 992, 14, 15264, 492, 3626, 12, 15397, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 2407, 63, 17438, 492, 6879, 2001, 2980, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 334, 272, 1413, 12, 6912, 2354, 12, 1104, 63, 3369, 63, 3892, 63, 15390, 12, 15749, 63, 5599, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 334, 272, 32272, 12, 491, 1877, 540, 12, 16044, 63, 3022, 12, 16044, 63, 10764, 12, 7813, 9418, 63, 1157, 3053, 12, 8655, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 23004, 492, 334, 272, 3523, 3186, 12, 9630, 12, 9630, 21722, 12, 25733, 12, 6879, 13005, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 4509, 492, 334, 272, 2401, 12, 1549, 12, 11177, 26493, 12, 20550, 1716, 12, 17685, 1716, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 6019, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 2350, 492, 5013, 199, 199, 363, 452, 363, 275, 788, 3227, 297, 283, 7963, 3227, 418, 421, 199, 318, 664, 63, 698, 63, 1247, 63, 504, 63, 3291, 8, 3291, 304, 272, 372, 663, 8, 4429, 14, 504, 63, 8147, 8, 267, 334, 70, 14, 354, 12, 289, 14, 13651, 9, 340, 289, 14, 13455, 587, 334, 70, 14, 354, 4258, 267, 367, 289, 315, 3999, 14, 362, 63, 955, 342, 272, 5082, 421, 199, 533, 13480, 3227, 8, 785, 304, 272, 408, 272, 437, 2849, 3066, 5385, 1827, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3875, 12, 1808, 12, 1862, 29, 403, 12, 1067, 29, 403, 304, 267, 291, 14, 1162, 275, 1862, 503, 6248, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 4941, 275, 1808, 267, 291, 14, 3937, 275, 488, 398, 327, 603, 7932, 2005, 4382, 402, 282, 3293, 1827, 880, 626, 267, 327, 314, 6365, 883, 506, 1202, 370, 2112, 2058, 14, 267, 291, 14, 674, 63, 1657, 12, 291, 14, 6260, 63, 1657, 275, 378, 12, 488, 221, 327, 8051, 367, 3268, 15, 3097, 267, 291, 14, 2911, 63, 2416, 275, 1052, 267, 291, 14, 9340, 63, 2416, 275, 1052, 267, 291, 14, 1100, 275, 1067, 503, 1052, 339, 347, 7289, 8, 277, 12, 1808, 304, 267, 372, 13480, 3227, 8, 277, 14, 3009, 12, 1808, 12, 1862, 29, 277, 14, 1162, 12, 1067, 29, 277, 14, 1100, 14, 1574, 1012, 339, 347, 664, 63, 3406, 8, 277, 304, 267, 340, 291, 14, 3937, 365, 488, 26, 288, 291, 423, 2526, 63, 1131, 342, 267, 11109, 275, 6947, 59, 277, 14, 4941, 1055, 21627, 14, 2301, 63, 354, 63, 11256, 267, 372, 359, 11256, 8, 2301, 63, 2024, 59, 16, 566, 355, 367, 2763, 63, 2024, 315, 291, 14, 3937, 14, 1802, 61, 339, 347, 636, 1661, 721, 277, 304, 267, 327, 16763, 5341, 282, 892, 1827, 367, 282, 892, 6122, 14, 267, 327, 961, 4293, 506, 20212, 543, 282, 2581, 737, 314, 26963, 402, 30207, 14, 267, 291, 423, 2526, 63, 1131, 342, 267, 340, 440, 6947, 59, 277, 14, 4941, 1055, 3179, 14, 2425, 63, 1180, 63, 19955, 63, 15656, 26, 288, 327, 982, 314, 3050, 883, 1133, 675, 22180, 11597, 781, 1929, 370, 1852, 3238, 781, 288, 327, 9352, 314, 8039, 1827, 1536, 13738, 14, 288, 754, 275, 769, 8, 277, 14, 3937, 9, 267, 587, 26, 288, 754, 275, 291, 14, 3937, 267, 372, 2740, 8, 1099, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 7963, 3227, 26, 450, 83, 4335, 450, 291, 339, 768, 1829, 272, 347, 1862, 63, 466, 8, 277, 304, 267, 372, 1211, 340, 1228, 8, 277, 14, 1162, 12, 12340, 9, 587, 2008, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 3009, 450, 291, 14, 1162, 63, 466, 8, 277, 14, 1162, 9, 339, 347, 485, 2526, 63, 1131, 8, 277, 304, 267, 1950, 275, 6947, 59, 277, 14, 4941, 61, 398, 327, 4431, 6182, 2633, 370, 314, 3050, 12, 465, 8298, 465, 3962, 11201, 316, 267, 327, 626, 314, 1347, 730, 5712, 1133, 6040, 14, 1666, 327, 8881, 1229, 14, 267, 1862, 63, 466, 275, 291, 14, 1162, 63, 466, 267, 12146, 275, 1950, 14, 1483, 14, 19609, 63, 5187, 63, 585, 267, 340, 1862, 63, 466, 365, 2008, 26, 288, 1862, 275, 2008, 8, 10394, 8, 637, 9, 367, 1139, 315, 291, 14, 1162, 9, 267, 916, 1862, 63, 466, 365, 1211, 26, 288, 1862, 275, 1211, 1332, 498, 12, 12146, 8, 637, 430, 367, 790, 12, 1139, 315, 3816, 14, 4611, 8, 277, 14, 1162, 430, 267, 587, 26, 288, 746, 6064, 480, 8708, 1862, 730, 26, 450, 83, 2, 450, 1862, 63, 466, 9, 398, 291, 14, 3937, 275, 1950, 14, 3937, 342, 267, 291, 14, 3937, 14, 2526, 8, 277, 14, 3009, 12, 1862, 9, 421, 199, 533, 8133, 8, 785, 304, 272, 408, 272, 437, 2849, 5385, 1827, 14, 272, 408, 339, 5162, 63, 1861, 275 ]
[ 199, 2499, 5385, 9834, 367, 8133, 9899, 14, 199, 199, 1918, 1233, 315, 2348, 22667, 15409, 1006, 402, 314, 5385, 14538, 880, 626, 8133, 9899, 199, 1589, 77, 16887, 886, 440, 1172, 370, 334, 460, 4293, 506, 1771, 379, 701, 7645, 1163, 2419, 5385, 199, 17439, 680, 710, 2236, 29639, 29741, 1454, 5419, 1373, 4340, 26, 642, 859, 965, 370, 5715, 199, 452, 3595, 314, 5007, 83, 402, 1709, 315, 1865, 370, 664, 314, 2556, 652, 4839, 14, 199, 624, 199, 646, 1331, 199, 646, 3598, 199, 504, 5055, 492, 14427, 12, 25769, 12, 12340, 12, 8773, 199, 504, 7975, 492, 6036, 12, 2338, 12, 3336, 199, 504, 1059, 492, 13294, 63, 26831, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 12, 27691, 199, 504, 1639, 14, 697, 492, 6186, 63, 2846, 63, 12644, 12, 6947, 199, 504, 1639, 14, 697, 14, 992, 14, 21622, 492, 14826, 199, 504, 1639, 14, 697, 14, 992, 14, 5559, 492, 3412, 3593, 2160, 63, 20848, 199, 504, 1639, 14, 697, 14, 992, 14, 15264, 492, 3626, 12, 15397, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 2407, 63, 17438, 492, 6879, 2001, 2980, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 334, 272, 1413, 12, 6912, 2354, 12, 1104, 63, 3369, 63, 3892, 63, 15390, 12, 15749, 63, 5599, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 5559, 492, 334, 272, 32272, 12, 491, 1877, 540, 12, 16044, 63, 3022, 12, 16044, 63, 10764, 12, 7813, 9418, 63, 1157, 3053, 12, 8655, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 23004, 492, 334, 272, 3523, 3186, 12, 9630, 12, 9630, 21722, 12, 25733, 12, 6879, 13005, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 3009, 14, 4509, 492, 334, 272, 2401, 12, 1549, 12, 11177, 26493, 12, 20550, 1716, 12, 17685, 1716, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 6019, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 2350, 492, 5013, 199, 199, 363, 452, 363, 275, 788, 3227, 297, 283, 7963, 3227, 418, 421, 199, 318, 664, 63, 698, 63, 1247, 63, 504, 63, 3291, 8, 3291, 304, 272, 372, 663, 8, 4429, 14, 504, 63, 8147, 8, 267, 334, 70, 14, 354, 12, 289, 14, 13651, 9, 340, 289, 14, 13455, 587, 334, 70, 14, 354, 4258, 267, 367, 289, 315, 3999, 14, 362, 63, 955, 342, 272, 5082, 421, 199, 533, 13480, 3227, 8, 785, 304, 272, 408, 272, 437, 2849, 3066, 5385, 1827, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3875, 12, 1808, 12, 1862, 29, 403, 12, 1067, 29, 403, 304, 267, 291, 14, 1162, 275, 1862, 503, 6248, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 4941, 275, 1808, 267, 291, 14, 3937, 275, 488, 398, 327, 603, 7932, 2005, 4382, 402, 282, 3293, 1827, 880, 626, 267, 327, 314, 6365, 883, 506, 1202, 370, 2112, 2058, 14, 267, 291, 14, 674, 63, 1657, 12, 291, 14, 6260, 63, 1657, 275, 378, 12, 488, 221, 327, 8051, 367, 3268, 15, 3097, 267, 291, 14, 2911, 63, 2416, 275, 1052, 267, 291, 14, 9340, 63, 2416, 275, 1052, 267, 291, 14, 1100, 275, 1067, 503, 1052, 339, 347, 7289, 8, 277, 12, 1808, 304, 267, 372, 13480, 3227, 8, 277, 14, 3009, 12, 1808, 12, 1862, 29, 277, 14, 1162, 12, 1067, 29, 277, 14, 1100, 14, 1574, 1012, 339, 347, 664, 63, 3406, 8, 277, 304, 267, 340, 291, 14, 3937, 365, 488, 26, 288, 291, 423, 2526, 63, 1131, 342, 267, 11109, 275, 6947, 59, 277, 14, 4941, 1055, 21627, 14, 2301, 63, 354, 63, 11256, 267, 372, 359, 11256, 8, 2301, 63, 2024, 59, 16, 566, 355, 367, 2763, 63, 2024, 315, 291, 14, 3937, 14, 1802, 61, 339, 347, 636, 1661, 721, 277, 304, 267, 327, 16763, 5341, 282, 892, 1827, 367, 282, 892, 6122, 14, 267, 327, 961, 4293, 506, 20212, 543, 282, 2581, 737, 314, 26963, 402, 30207, 14, 267, 291, 423, 2526, 63, 1131, 342, 267, 340, 440, 6947, 59, 277, 14, 4941, 1055, 3179, 14, 2425, 63, 1180, 63, 19955, 63, 15656, 26, 288, 327, 982, 314, 3050, 883, 1133, 675, 22180, 11597, 781, 1929, 370, 1852, 3238, 781, 288, 327, 9352, 314, 8039, 1827, 1536, 13738, 14, 288, 754, 275, 769, 8, 277, 14, 3937, 9, 267, 587, 26, 288, 754, 275, 291, 14, 3937, 267, 372, 2740, 8, 1099, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 7963, 3227, 26, 450, 83, 4335, 450, 291, 339, 768, 1829, 272, 347, 1862, 63, 466, 8, 277, 304, 267, 372, 1211, 340, 1228, 8, 277, 14, 1162, 12, 12340, 9, 587, 2008, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 3009, 450, 291, 14, 1162, 63, 466, 8, 277, 14, 1162, 9, 339, 347, 485, 2526, 63, 1131, 8, 277, 304, 267, 1950, 275, 6947, 59, 277, 14, 4941, 61, 398, 327, 4431, 6182, 2633, 370, 314, 3050, 12, 465, 8298, 465, 3962, 11201, 316, 267, 327, 626, 314, 1347, 730, 5712, 1133, 6040, 14, 1666, 327, 8881, 1229, 14, 267, 1862, 63, 466, 275, 291, 14, 1162, 63, 466, 267, 12146, 275, 1950, 14, 1483, 14, 19609, 63, 5187, 63, 585, 267, 340, 1862, 63, 466, 365, 2008, 26, 288, 1862, 275, 2008, 8, 10394, 8, 637, 9, 367, 1139, 315, 291, 14, 1162, 9, 267, 916, 1862, 63, 466, 365, 1211, 26, 288, 1862, 275, 1211, 1332, 498, 12, 12146, 8, 637, 430, 367, 790, 12, 1139, 315, 3816, 14, 4611, 8, 277, 14, 1162, 430, 267, 587, 26, 288, 746, 6064, 480, 8708, 1862, 730, 26, 450, 83, 2, 450, 1862, 63, 466, 9, 398, 291, 14, 3937, 275, 1950, 14, 3937, 342, 267, 291, 14, 3937, 14, 2526, 8, 277, 14, 3009, 12, 1862, 9, 421, 199, 533, 8133, 8, 785, 304, 272, 408, 272, 437, 2849, 5385, 1827, 14, 272, 408, 339, 5162, 63, 1861, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
laslabs/connector-telephony
asterisk_click2dial_crm/__openerp__.py
8
1784
# -*- encoding: utf-8 -*- ############################################################################## # # Asterisk click2dial CRM module for OpenERP # Copyright (c) 2012-2014 Akretion (http://www.akretion.com) # @author: Alexis de Lattre <alexis.delattre@akretion.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { "name": "Asterisk Click2dial CRM", "version": "0.1", "author": "Akretion,Odoo Community Association (OCA)", "website": "http://www.akretion.com", "license": "AGPL-3", "category": "Phone", "description": """ Asterisk Click2dial CRM ======================= This module is *EMPTY* ; so you should uninstall it now. The code that used to be in this module has been moved to the module *crm_phone* that is available in the same GitHub repository https://github.com/OCA/connector-telephony This module will be removed from the repository in the near future. """, "depends": [ 'asterisk_click2dial', 'crm_phone', ], "data": [], "installable": True, "application": False, }
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 437, 1597, 27473, 8968, 18, 328, 279, 445, 11026, 859, 367, 7653, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 7280, 437, 75, 264, 296, 334, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 9, 199, 3, 259, 768, 2502, 26, 22986, 374, 477, 491, 6796, 264, 665, 1895, 7291, 14, 2264, 6796, 264, 32, 1151, 264, 296, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 259, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 298, 354, 582, 298, 33, 1597, 27473, 26147, 18, 328, 279, 445, 11026, 401, 272, 298, 1023, 582, 298, 16, 14, 17, 401, 272, 298, 2502, 582, 298, 33, 75, 264, 296, 12, 47, 16766, 7046, 6639, 24207, 425, 334, 47, 3263, 4186, 272, 298, 7360, 582, 298, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 401, 272, 298, 1682, 582, 298, 1254, 2749, 13, 19, 401, 272, 298, 3710, 582, 298, 15199, 401, 272, 298, 1802, 582, 408, 199, 33, 1597, 27473, 26147, 18, 328, 279, 445, 11026, 199, 1280, 18673, 199, 199, 2765, 859, 365, 627, 13993, 10, 8700, 880, 1265, 1077, 22199, 652, 3063, 14, 199, 1918, 1233, 626, 1202, 370, 506, 315, 642, 859, 965, 2757, 12155, 370, 314, 859, 199, 10, 15213, 63, 9339, 10, 626, 365, 2808, 315, 314, 2011, 25141, 7611, 199, 2859, 921, 5031, 14, 957, 15, 47, 3263, 15, 11815, 13, 15253, 838, 5220, 199, 199, 2765, 859, 911, 506, 4829, 687, 314, 7611, 315, 314, 17429, 6466, 14, 199, 7208, 272, 298, 8912, 582, 359, 267, 283, 305, 6236, 1339, 63, 4891, 18, 328, 279, 297, 267, 283, 15213, 63, 9339, 297, 272, 2156, 272, 298, 576, 582, 990, 272, 298, 21762, 582, 715, 12, 272, 298, 3578, 582, 756, 12, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 437, 1597, 27473, 8968, 18, 328, 279, 445, 11026, 859, 367, 7653, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 7280, 437, 75, 264, 296, 334, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 9, 199, 3, 259, 768, 2502, 26, 22986, 374, 477, 491, 6796, 264, 665, 1895, 7291, 14, 2264, 6796, 264, 32, 1151, 264, 296, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 259, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 298, 354, 582, 298, 33, 1597, 27473, 26147, 18, 328, 279, 445, 11026, 401, 272, 298, 1023, 582, 298, 16, 14, 17, 401, 272, 298, 2502, 582, 298, 33, 75, 264, 296, 12, 47, 16766, 7046, 6639, 24207, 425, 334, 47, 3263, 4186, 272, 298, 7360, 582, 298, 1014, 921, 1544, 14, 1151, 264, 296, 14, 957, 401, 272, 298, 1682, 582, 298, 1254, 2749, 13, 19, 401, 272, 298, 3710, 582, 298, 15199, 401, 272, 298, 1802, 582, 408, 199, 33, 1597, 27473, 26147, 18, 328, 279, 445, 11026, 199, 1280, 18673, 199, 199, 2765, 859, 365, 627, 13993, 10, 8700, 880, 1265, 1077, 22199, 652, 3063, 14, 199, 1918, 1233, 626, 1202, 370, 506, 315, 642, 859, 965, 2757, 12155, 370, 314, 859, 199, 10, 15213, 63, 9339, 10, 626, 365, 2808, 315, 314, 2011, 25141, 7611, 199, 2859, 921, 5031, 14, 957, 15, 47, 3263, 15, 11815, 13, 15253, 838, 5220, 199, 199, 2765, 859, 911, 506, 4829, 687, 314, 7611, 315, 314, 17429, 6466, 14, 199, 7208, 272, 298, 8912, 582, 359, 267, 283, 305, 6236, 1339, 63, 4891, 18, 328, 279, 297, 267, 283, 15213, 63, 9339, 297, 272, 2156, 272, 298, 576, 582, 990, 272, 298, 21762, 582, 715, 12, 272, 298, 3578, 582, 756, 12, 199, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bealdav/OCB
addons/stock/partner.py
375
1766
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv class res_partner(osv.osv): _inherit = 'res.partner' _columns = { 'property_stock_customer': fields.property( type='many2one', relation='stock.location', string="Customer Location", help="This stock location will be used, instead of the default one, as the destination location for goods you send to this partner"), 'property_stock_supplier': fields.property( type='many2one', relation='stock.location', string="Supplier Location", help="This stock location will be used, instead of the default one, as the source location for goods you receive from the current partner"), } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 272, 485, 3406, 275, 469, 267, 283, 1829, 63, 6088, 63, 10178, 356, 1504, 14, 1829, 8, 881, 730, 534, 3479, 18, 368, 297, 881, 5850, 534, 6088, 14, 1985, 297, 881, 1059, 628, 17025, 12625, 401, 881, 1720, 628, 2765, 10952, 2909, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 465, 314, 5724, 2909, 367, 6954, 83, 1265, 3222, 370, 642, 5854, 1288, 267, 283, 1829, 63, 6088, 63, 17294, 356, 1504, 14, 1829, 8, 881, 730, 534, 3479, 18, 368, 297, 881, 5850, 534, 6088, 14, 1985, 297, 881, 1059, 628, 30080, 12625, 401, 881, 1720, 628, 2765, 10952, 2909, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 465, 314, 1350, 2909, 367, 6954, 83, 1265, 9128, 687, 314, 1453, 5854, 1288, 272, 789, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 272, 485, 3406, 275, 469, 267, 283, 1829, 63, 6088, 63, 10178, 356, 1504, 14, 1829, 8, 881, 730, 534, 3479, 18, 368, 297, 881, 5850, 534, 6088, 14, 1985, 297, 881, 1059, 628, 17025, 12625, 401, 881, 1720, 628, 2765, 10952, 2909, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 465, 314, 5724, 2909, 367, 6954, 83, 1265, 3222, 370, 642, 5854, 1288, 267, 283, 1829, 63, 6088, 63, 17294, 356, 1504, 14, 1829, 8, 881, 730, 534, 3479, 18, 368, 297, 881, 5850, 534, 6088, 14, 1985, 297, 881, 1059, 628, 30080, 12625, 401, 881, 1720, 628, 2765, 10952, 2909, 911, 506, 1202, 12, 3140, 402, 314, 849, 1373, 12, 465, 314, 1350, 2909, 367, 6954, 83, 1265, 9128, 687, 314, 1453, 5854, 1288, 272, 789, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
status-im/status-react
test/appium/tests/atomic/account_management/test_profile.py
1
71527
import re from tests import marks, bootnode_address, mailserver_address, test_dapp_url, test_dapp_name, mailserver_ams, \ mailserver_gc, mailserver_hk, used_fleet, common_password from tests.base_test_case import SingleDeviceTestCase, MultipleDeviceTestCase from tests.users import transaction_senders, basic_user, ens_user, ens_user_ropsten from views.sign_in_view import SignInView from time import time class TestProfileSingleDevice(SingleDeviceTestCase): @marks.testrail_id(6318) @marks.medium def test_can_delete_several_multiaccounts(self): sign_in = SignInView(self.driver) sign_in.create_user() delete_alert_warning = sign_in.get_translation_by_key("delete-profile-warning") profile = sign_in.profile_button.click() profile.logout() if sign_in.ok_button.is_element_displayed(): sign_in.ok_button.click() sign_in.back_button.click() sign_in.your_keys_more_icon.click() sign_in.generate_new_key_button.click() sign_in.next_button.click() sign_in.next_button.click() sign_in.create_password_input.set_value(common_password) sign_in.next_button.click() sign_in.confirm_your_password_input.set_value(common_password) sign_in.next_button.click() sign_in.maybe_later_button.click_until_presence_of_element(sign_in.lets_go_button) sign_in.lets_go_button.click() sign_in.just_fyi('Delete 2nd multiaccount') public_key, username = sign_in.get_public_key_and_username(return_username=True) profile.privacy_and_security_button.click() profile.delete_my_profile_button.scroll_and_click() for text in (username, delete_alert_warning): if not profile.element_by_text(text).is_element_displayed(): self.errors.append('Required %s is not shown when deleting multiaccount' % text) profile.delete_profile_button.click() if profile.element_by_translation_id("profile-deleted-title").is_element_displayed(): self.driver.fail('Profile is deleted without confirmation with password') profile.delete_my_profile_password_input.set_value(common_password) profile.delete_profile_button.click_until_presence_of_element(profile.element_by_translation_id("profile-deleted-title")) profile.ok_button.click() sign_in.just_fyi('Delete last multiaccount') sign_in.sign_in() sign_in.profile_button.click() profile.privacy_and_security_button.click() profile.delete_my_profile_button.scroll_and_click() profile.delete_my_profile_password_input.set_value(common_password) profile.delete_profile_button.click() profile.ok_button.click() if not sign_in.get_started_button.is_element_displayed(20): self.errors.append('No redirected to carousel view after deleting last multiaccount') self.errors.verify_no_errors() @marks.testrail_id(5323) @marks.critical def test_share_copy_contact_code_and_wallet_address(self): home = SignInView(self.driver).create_user() profile = home.profile_button.click() home.just_fyi("Copying contact code") profile.share_my_profile_button.click() public_key = profile.public_key_text.text profile.public_key_text.long_press_element() profile.copy_text() home.just_fyi("Sharing contact code via messenger") profile.share_button.click() profile.share_via_messenger() if not profile.element_by_text_part(public_key).is_element_present(): self.errors.append("Can't share public key") [profile.click_system_back_button() for _ in range(2)] profile.close_share_popup() home.just_fyi("Check that can paste contact code in chat message input") home = profile.home_button.click() chat = home.add_contact(transaction_senders['M']['public_key']) chat.chat_message_input.click() chat.paste_text() input_text = chat.chat_message_input.text if input_text not in public_key or len(input_text) < 1: self.errors.append('Public key was not copied') chat.chat_message_input.clear() chat.get_back_to_home_view() home.just_fyi("Copying wallet address") wallet = profile.wallet_button.click() wallet.set_up_wallet() wallet.accounts_status_account.click() request = wallet.receive_transaction_button.click() address = wallet.address_text.text request.share_button.click() request.element_by_translation_id("sharing-copy-to-clipboard").click() home.just_fyi("Sharing wallet address via messenger") request.share_button.click() wallet.share_via_messenger() if not wallet.element_by_text_part(address).is_element_present(): self.errors.append("Can't share address") [wallet.click_system_back_button() for _ in range(2)] wallet.close_share_popup() home.just_fyi("Check that can paste wallet address in chat message input") wallet.home_button.click() home.get_chat(transaction_senders['M']['username']).click() chat.chat_message_input.click() chat.paste_text() if chat.chat_message_input.text != address: self.errors.append('Wallet address was not copied') self.errors.verify_no_errors() @marks.testrail_id(5502) @marks.critical def test_can_add_existing_ens(self): home = SignInView(self.driver).recover_access(ens_user['passphrase']) profile = home.profile_button.click() profile.switch_network('Mainnet with upstream RPC') home.profile_button.click() dapp_view = profile.ens_usernames_button.click() dapp_view.just_fyi('check if your name can be added via "ENS usernames" in Profile') dapp_view.element_by_text('Get started').click() dapp_view.ens_name_input.set_value(ens_user['ens']) dapp_view.check_ens_name.click_until_absense_of_element(dapp_view.check_ens_name) if not dapp_view.element_by_translation_id('ens-saved-title').is_element_displayed(): self.errors.append('No message "Username added" after resolving own username') dapp_view.element_by_translation_id("ens-got-it").click() dapp_view.just_fyi('check that after adding username is shown in "ENS usernames" and profile') if not dapp_view.element_by_text(ens_user['ens']).is_element_displayed(): self.errors.append('No ENS name is shown in own "ENS usernames" after adding') dapp_view.back_button.click() if not dapp_view.element_by_text('@%s' % ens_user['ens']).is_element_displayed(): self.errors.append('No ENS name is shown in own profile after adding') if not dapp_view.element_by_text('%s.stateofus.eth' % ens_user['ens']).is_element_displayed(): self.errors.append('No ENS name is shown in own profile after adding') profile.share_my_profile_button.click() if profile.ens_name_in_share_chat_key_text.text != '%s.stateofus.eth' % ens_user['ens']: self.errors.append('No ENS name is shown on tapping on share icon in Profile') profile.close_share_popup() self.errors.verify_no_errors() @marks.testrail_id(6296) @marks.high def test_recover_account_from_new_user_seedphrase(self): sign_in_view = SignInView(self.driver) sign_in_view.create_user() profile_view = sign_in_view.profile_button.click() profile_view.privacy_and_security_button.click() profile_view.backup_recovery_phrase_button.click() profile_view.ok_continue_button.click() recovery_phrase = " ".join(profile_view.get_recovery_phrase().values()) profile_view.close_button.click() profile_view.back_button.click() public_key = profile_view.get_public_key_and_username() wallet_view = profile_view.wallet_button.click() wallet_view.set_up_wallet() address = wallet_view.get_wallet_address() sign_in_view.profile_button.click() profile_view.logout() self.driver.reset() sign_in_view.recover_access(recovery_phrase) wallet_view = sign_in_view.wallet_button.click() wallet_view.set_up_wallet() if wallet_view.get_wallet_address() != address: self.driver.fail("Seed phrase displayed in new accounts for back up does not recover respective address") profile_view = wallet_view.profile_button.click() if profile_view.get_public_key_and_username() != public_key: self.driver.fail("Seed phrase displayed in new accounts for back up does not recover respective public key") @marks.testrail_id(5433) @marks.medium def test_invite_friends(self): home = SignInView(self.driver).create_user() self.driver.info("Check it via 'Invite friends' on home view") home.invite_friends_button.click() home.share_via_messenger() home.element_by_text_part("Hey join me on Status: https://join.status.im/u/0x") home.click_system_back_button() self.driver.info("Check it via bottom sheet menu") home.plus_button.click() home.chats_menu_invite_friends_button.click() home.share_via_messenger() home.element_by_text_part("Hey join me on Status: https://join.status.im/u/0x") @marks.testrail_id(6312) @marks.medium def test_add_remove_contact_via_contacts_view(self): home = SignInView(self.driver).create_user() home.just_fyi('Check empty contacts view') profile = home.profile_button.click() profile.switch_network() home.profile_button.click() profile.contacts_button.click() if not profile.add_new_contact_button.is_element_displayed(): self.driver.fail('No expected element on contacts view') users = { 'scanning_ens_with_stateofus_domain_deep_link': { 'contact_code': 'https://join.status.im/u/%s.stateofus.eth' % ens_user_ropsten['ens'], 'username': ens_user_ropsten['username'] }, 'scanning_public_key': { 'contact_code': transaction_senders['A']['public_key'], 'username': transaction_senders['A']['username'], }, 'pasting_public_key': { 'contact_code': basic_user['public_key'], 'username': basic_user['username'], }, 'pasting_ens_another_domain': { 'contact_code': ens_user['ens_another_domain'], 'username': '@%s' % ens_user['ens_another_domain'], 'nickname': 'my_dear_friend' }, } home.just_fyi('Add contact and check that they appear in Contacts view') chat_view = home.get_chat_view() for key in users: profile.add_new_contact_button.click() home.just_fyi('Checking %s case' % key) if 'scanning' in key: chat_view.scan_contact_code_button.click() if chat_view.allow_button.is_element_displayed(): chat_view.allow_button.click() chat_view.enter_qr_edit_box.scan_qr(users[key]['contact_code']) else: chat_view.public_key_edit_box.click() chat_view.public_key_edit_box.send_keys(users[key]['contact_code']) if 'nickname' in users[key]: chat_view.nickname_input_field.set_value(users[key]['nickname']) chat_view.confirm_until_presence_of_element(profile.contacts_button) if not profile.element_by_text(users[key]['username']).is_element_displayed(): self.errors.append('In %s case username not found in contact view after scanning' % key) if 'nickname' in users[key]: if not profile.element_by_text(users[key]['nickname']).is_element_displayed(): self.errors.append('In %s case nickname %s not found in contact view after scanning' % (key, users[key]['nickname'])) home.just_fyi('Remove contact and check that it disappeared') user_to_remove = '@%s' % ens_user['ens_another_domain'] profile.element_by_text(user_to_remove).click() chat_view.remove_from_contacts.click() chat_view.close_button.click() if profile.element_by_text(user_to_remove).is_element_displayed(): self.errors.append('Removed user is still shown in contact view') home.just_fyi('Relogin and open profile view of the contact removed from Contact list to ensure there is no crash') profile.profile_button.click() profile.relogin() one_to_one_chat = home.add_contact(public_key=ens_user['ens_another_domain'], add_in_contacts=False) one_to_one_chat.chat_options.click() profile = one_to_one_chat.view_profile_button.click() if profile.remove_from_contacts.is_element_displayed(): self.errors.append('User still added in contact after relogin') self.errors.verify_no_errors() @marks.testrail_id(5431) @marks.medium def test_add_custom_network(self): sign_in = SignInView(self.driver) sign_in.create_user() profile = sign_in.profile_button.click() profile.add_custom_network() sign_in.sign_in() sign_in.profile_button.click() profile.advanced_button.click() profile.network_settings_button.scroll_to_element(10, 'up') if not profile.element_by_text_part('custom_ropsten').is_element_displayed(): self.driver.fail("Network custom_ropsten was not added!") @marks.critical @marks.testrail_id(5419) @marks.flaky def test_logcat_backup_recovery_phrase(self): sign_in = SignInView(self.driver) home = sign_in.create_user() home.just_fyi("Check that badge on profile about back up seed phrase is presented") if home.profile_button.counter.text != '1': self.errors.append('Profile button counter is not shown') home.just_fyi("Back up seed phrase and check logcat") profile = home.profile_button.click() profile.privacy_and_security_button.click() profile.backup_recovery_phrase_button.click() profile.ok_continue_button.click() recovery_phrase = profile.get_recovery_phrase() profile.next_button.click() word_number = profile.recovery_phrase_word_number.number profile.recovery_phrase_word_input.set_value(recovery_phrase[word_number]) profile.next_button.click() word_number_1 = profile.recovery_phrase_word_number.number profile.recovery_phrase_word_input.set_value(recovery_phrase[word_number_1]) profile.done_button.click() profile.yes_button.click() profile.ok_got_it_button.click() if home.profile_button.counter.is_element_displayed(): self.errors.append('Profile button counter is shown after recovery phrase backup') values_in_logcat = profile.find_values_in_logcat(passphrase1=recovery_phrase[word_number], passphrase2=recovery_phrase[word_number_1]) if len(values_in_logcat) == 2: self.driver.fail(values_in_logcat) profile.profile_button.double_click() home.just_fyi("Try to restore same account from seed phrase (should be possible only to unlock existing account)") profile.logout() sign_in.back_button.click() sign_in.access_key_button.click() sign_in.enter_seed_phrase_button.click() sign_in.seedphrase_input.click() sign_in.seedphrase_input.set_value(' '.join(recovery_phrase.values())) sign_in.next_button.click() sign_in.element_by_translation_id(id="unlock", uppercase=True).click() sign_in.password_input.set_value(common_password) chat = sign_in.sign_in_button.click() chat.plus_button.click() if not chat.start_new_chat_button.is_element_displayed(): self.errors.append("Can't proceed using account after it's re-recover twice.") self.errors.verify_no_errors() @marks.testrail_id(5453) @marks.medium @marks.flaky def test_privacy_policy_terms_of_use_node_version_need_help_in_profile(self): signin = SignInView(self.driver) no_link_found_error_msg = 'Could not find privacy policy link at' no_link_open_error_msg = 'Could not open our privacy policy from' no_link_tos_error_msg = 'Could not open Terms of Use from' signin.just_fyi("Checking privacy policy from sign in") if not signin.privacy_policy_link.is_element_present(): self.driver.fail('%s Sign in view!' % no_link_found_error_msg) web_page = signin.privacy_policy_link.click() web_page.open_in_webview() if not web_page.policy_summary.is_element_displayed(): self.errors.append('%s Sign in view!' % no_link_open_error_msg) web_page.close_privacy_policy_button.click() signin.just_fyi("Checking Terms of Use from sign") if not signin.terms_of_use_link.is_element_displayed(): self.driver.fail("No Terms of Use link on Sign in view!") web_page = signin.terms_of_use_link.click() web_page.open_in_webview() web_page.wait_for_d_aap_to_load() web_page.swipe_by_custom_coordinates(0.5,0.8,0.5,0.4) if not web_page.terms_of_use_summary.is_element_displayed(): self.errors.append('%s Sign in view!' % no_link_tos_error_msg) web_page.close_privacy_policy_button.click() home = signin.create_user() profile = home.profile_button.click() profile.about_button.click() profile.privacy_policy_button.click() if not web_page.policy_summary.is_element_displayed(): self.errors.append('%s Profile about view!' % no_link_open_error_msg) web_page.click_system_back_button() profile.terms_of_use_button.click() web_page.wait_for_d_aap_to_load() web_page.swipe_by_custom_coordinates(0.5,0.8,0.5,0.4) if not web_page.terms_of_use_summary.is_element_displayed(): self.errors.append('%s Profile about view!' % no_link_tos_error_msg) web_page.click_system_back_button() signin.just_fyi("Checking that version match expected format and can be copied") app_version = profile.app_version_text.text node_version = profile.node_version_text.text if not re.search(r'\d{1}[.]\d{1,2}[.]\d{1,2}\s[(]\d*[)]', app_version): self.errors.append("App version %s didn't match expected format" % app_version) if not re.search(r'StatusIM\/v.*\/android-\d{3}\/go\d{1}[.]\d{1,}', node_version): self.errors.append("Node version %s didn't match expected format" % node_version) profile.app_version_text.click() profile.back_button.click() profile.home_button.click() chat = home.join_public_chat(home.get_random_chat_name()) message_input = chat.chat_message_input message_input.paste_text_from_clipboard() if message_input.text != app_version: self.errors.append('Version number was not copied to clipboard') signin.just_fyi("Checking Need help section") home.profile_button.double_click() profile.help_button.click() web_page = profile.faq_button.click() web_page.open_in_webview() web_page.wait_for_d_aap_to_load() if not profile.element_by_text_part("F.A.Q").is_element_displayed(): self.errors.append("FAQ is not shown") profile.click_system_back_button() profile.submit_bug_button.click() if not profile.element_by_text_part("Welcome to Gmail").is_element_displayed(): self.errors.append("Mail client is not opened when submitting bug") profile.click_system_back_button() profile.request_a_feature_button.click() if not profile.element_by_text("#support").is_element_displayed(): self.errors.append("Support channel is not suggested for requesting a feature") self.errors.verify_no_errors() @marks.testrail_id(5738) @marks.high def test_dapps_permissions(self): home = SignInView(self.driver).create_user() account_name = home.status_account_name home.just_fyi('open Status Test Dapp, allow all and check permissions in Profile') web_view = home.open_status_test_dapp() dapp_view = home.dapp_tab_button.click() profile = home.profile_button.click() profile.privacy_and_security_button.click() profile.dapp_permissions_button.click() profile.element_by_text(test_dapp_name).click() if not profile.element_by_text(account_name).is_element_displayed(): self.errors.append('Wallet permission was not granted') if not profile.element_by_translation_id("chat-key").is_element_displayed(): self.errors.append('Contact code permission was not granted') profile.just_fyi('revoke access and check that they are asked second time') profile.revoke_access_button.click() profile.back_button.click() profile.dapp_tab_button.click() web_view.open_tabs_button.click() web_view.empty_tab_button.click() dapp_view.open_url(test_dapp_url) if not dapp_view.element_by_text_part(account_name).is_element_displayed(): self.errors.append('Wallet permission is not asked') if dapp_view.allow_button.is_element_displayed(): dapp_view.allow_button.click(times_to_click=1) if not dapp_view.element_by_translation_id("your-contact-code").is_element_displayed(): self.errors.append('Profile permission is not asked') self.errors.verify_no_errors() @marks.testrail_id(5368) @marks.medium def test_change_log_level_and_fleet(self): home = SignInView(self.driver).create_user() profile = home.profile_button.click() profile.advanced_button.click() default_log_level = 'INFO' for text in default_log_level, used_fleet: if not profile.element_by_text(text).is_element_displayed(): self.errors.append('%s is not selected by default' % text) if home.find_values_in_geth('lvl=trce', 'lvl=dbug'): self.errors.append('"%s" is set, but found another entries!' % default_log_level) if not home.find_values_in_geth('lvl=info'): self.errors.append('"%s" is set, but no entries are found!' % default_log_level) home.just_fyi('Set another loglevel and check that changes are applied') profile.log_level_setting_button.click() changed_log_level = 'TRACE' profile.element_by_text(changed_log_level).click_until_presence_of_element(profile.confirm_button) profile.confirm_button.click() SignInView(self.driver).sign_in() home.profile_button.click() profile.advanced_button.click() if not profile.element_by_text(changed_log_level).is_element_displayed(): self.errors.append('"%s" is not selected after change' % changed_log_level) if not home.find_values_in_geth('lvl=trc'): self.errors.append('"%s" is set, but no entries are found!' % changed_log_level) home.just_fyi('Set another fleet and check that changes are applied') profile.fleet_setting_button.click() changed_fleet = 'eth.prod' profile.element_by_text(changed_fleet).click_until_presence_of_element(profile.confirm_button) profile.confirm_button.click() SignInView(self.driver).sign_in() home.profile_button.click() profile.advanced_button.click() if not profile.element_by_text(changed_fleet).is_element_displayed(): self.errors.append('"%s" fleet is not selected after change' % changed_fleet) if not home.find_values_in_geth(changed_fleet): self.errors.append('"%s" is set, but no entry is found!' % changed_fleet) self.errors.verify_no_errors() @marks.testrail_id(5766) @marks.medium @marks.flaky def test_use_pinned_mailserver(self): home = SignInView(self.driver).create_user() profile = home.profile_button.click() profile.just_fyi('pin history node') profile.sync_settings_button.click() node_gc, node_ams, node_hk = [profile.return_mailserver_name(history_node_name, used_fleet) for history_node_name in (mailserver_gc, mailserver_ams, mailserver_hk)] h_node = node_ams profile.mail_server_button.click() profile.mail_server_auto_selection_button.click() profile.mail_server_by_name(h_node).click() profile.confirm_button.click() if profile.element_by_translation_id("mailserver-error-title").is_element_displayed(10): h_node = node_hk profile.element_by_translation_id("mailserver-pick-another", uppercase=True).click() profile.mail_server_by_name(h_node).click() profile.confirm_button.click() if profile.element_by_translation_id("mailserver-error-title").is_element_displayed(10): self.driver.fail("Couldn't connect to any history node") profile.just_fyi('check that history node is pinned') profile.close_button.click() if not profile.element_by_text(h_node).is_element_displayed(): self.errors.append('"%s" history node is not pinned' % h_node) profile.home_button.click() profile.just_fyi('Relogin and check that settings are preserved') home.relogin() home.profile_button.click() profile.sync_settings_button.click() if not profile.element_by_text(h_node).is_element_displayed(): self.errors.append('"%s" history node is not pinned' % h_node) self.errors.verify_no_errors() @marks.testrail_id(6219) @marks.medium def test_set_primary_ens_custom_domain(self): home = SignInView(self.driver).recover_access(ens_user['passphrase']) ens_not_stateofus = ens_user['ens_another_domain'] ens_stateofus = ens_user['ens'] home.just_fyi('add 2 ENS names in Profile') profile = home.profile_button.click() dapp = profile.connect_existing_status_ens(ens_stateofus) profile.element_by_text("Add username").click() profile.element_by_text_part("another domain").click() dapp.ens_name_input.set_value(ens_not_stateofus) dapp.check_ens_name.click_until_presence_of_element(dapp.element_by_translation_id("ens-got-it")) dapp.element_by_translation_id("ens-got-it").click() home.just_fyi('check that by default %s ENS is set' % ens_stateofus) dapp.element_by_text('Primary username').click() message_to_check = 'Your messages are displayed to others with' if not dapp.element_by_text('%s\n@%s.stateofus.eth' % (message_to_check, ens_stateofus)).is_element_displayed(): self.errors.append('%s ENS username is not set as primary by default' % ens_stateofus) home.just_fyi('check view in chat settings ENS from other domain: %s after set new primary ENS' % ens_not_stateofus) dapp.set_primary_ens_username(ens_user['ens_another_domain']).click() if profile.username_in_ens_chat_settings_text.text != '@' + ens_not_stateofus: self.errors.append('ENS username %s is not shown in ENS username Chat Settings after enabling' % ens_not_stateofus) self.errors.verify_no_errors() @marks.testrail_id(5468) @marks.medium @marks.skip # TODO: skip until profile picture change feature is enabled def test_deny_camera_access_changing_profile_photo(self): sign_in = SignInView(self.driver) sign_in.create_user() profile = sign_in.profile_button.click() profile.profile_picture.click() profile.capture_button.click() for _ in range(2): profile.deny_button.click() profile.element_by_translation_id("camera-access-error").wait_for_visibility_of_element(3) profile.ok_button.click() profile.profile_picture.click() profile.capture_button.click() profile.deny_button.wait_for_visibility_of_element(2) @marks.testrail_id(5469) @marks.medium @marks.skip # TODO: skip until profile picture change feature is enabled def test_deny_device_storage_access_changing_profile_photo(self): sign_in = SignInView(self.driver) sign_in.create_user() profile = sign_in.profile_button.click() profile.profile_picture.click() profile.select_from_gallery_button.click() profile.deny_button.click() profile.element_by_translation_id(id="external-storage-denied", element_type='text').wait_for_visibility_of_element(3) profile.ok_button.click() profile.profile_picture.click() profile.select_from_gallery_button.click() profile.deny_button.wait_for_visibility_of_element(2) class TestProfileMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(6646) @marks.high def test_set_profile_picture(self): self.create_drivers(2) home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user() profile_1 = home_1.profile_button.click() public_key_1 = profile_1.get_public_key_and_username() profile_1.just_fyi("Set user Profile image from Gallery") profile_1.edit_profile_picture(file_name='sauce_logo.png') home_1.profile_button.click() profile_1.swipe_down() if not profile_1.profile_picture.is_element_image_similar_to_template('sauce_logo_profile.png'): self.drivers[0].fail('Profile picture was not updated') profile_1.just_fyi("Check user profile updated in chat") home = profile_1.home_button.click() message = "Text message" public_chat_name = home.get_random_chat_name() home_2.add_contact(public_key=public_key_1) home_2.home_button.click() public_chat_2 = home_2.join_public_chat(public_chat_name) public_chat_1 = home.join_public_chat(public_chat_name) public_chat_1.chat_message_input.send_keys(message) public_chat_1.send_message_button.click() if not public_chat_2.chat_element_by_text(message).member_photo.is_element_image_similar_to_template('sauce_logo.png'): self.drivers[0].fail('Profile picture was not updated in chat') profile_1.just_fyi("Set user Profile image by taking Photo") home_1.profile_button.click() profile_1.edit_profile_picture(file_name='sauce_logo.png', update_by='Make Photo') home_1.home_button.click(desired_view='chat') public_chat_1.chat_message_input.send_keys(message) public_chat_1.send_message_button.click() if public_chat_2.chat_element_by_text(message).member_photo.is_element_image_similar_to_template('sauce_logo.png'): self.drivers[0].fail('Profile picture was not updated in chat after making photo') @marks.testrail_id(6636) @marks.medium def test_show_profile_picture_of_setting(self): self.create_drivers(2) home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user() profile_1 = home_1.profile_button.click() public_key_1, default_username_1 = profile_1.get_public_key_and_username(return_username=True) profile_1.just_fyi("Set user Profile image from Gallery") profile_1.edit_profile_picture(file_name='sauce_logo.png') home_1.profile_button.click() profile_1.swipe_down() profile_1.just_fyi('set status in profile') device_1_status = 'My new update!' timeline = profile_1.status_button.click() timeline.set_new_status(device_1_status) if not timeline.timeline_own_account_photo.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('Profile picture was not updated in timeline') profile_1.just_fyi('Check profile image it is not in mentions because user not in contacts yet') one_to_one_chat_2 = home_2.add_contact(public_key_1, add_in_contacts=False) one_to_one_chat_2.chat_message_input.set_value('@' + default_username_1) one_to_one_chat_2.chat_message_input.click() if one_to_one_chat_2.user_profile_image_in_mentions_list(default_username_1).is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('Profile picture is updated in 1-1 chat mentions list of contact not in Contacts list') profile_1.just_fyi('Check profile image is in mentions because now user was added in contacts') one_to_one_chat_2.add_to_contacts.click() one_to_one_chat_2.chat_message_input.set_value('@' + default_username_1) one_to_one_chat_2.chat_message_input.click() if not one_to_one_chat_2.user_profile_image_in_mentions_list(default_username_1).is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('Profile picture was not updated in 1-1 chat mentions list') profile_1.just_fyi('Check profile image updated in user profile view and on Chats view') profile_2 = one_to_one_chat_2.profile_button.click() profile_2.contacts_button.click() profile_2.element_by_text(default_username_1).click() if not profile_2.profile_picture.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('Profile picture was not updated on user Profile view') profile_2.close_button.click() one_to_one_chat_2.home_button.click(desired_view='home') if not home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('User profile picture was not updated on Chats view') profile_1.just_fyi('Check profile image updated in user profile view in Group chat views 4') home_1.home_button.click(desired_view='home') group_chat_message = 'Trololo' group_chat_2 = home_2.create_group_chat(user_names_to_add=[default_username_1]) group_chat_2.send_message('Message') group_chat_1 = home_1.get_chat('new_group_chat').click() group_chat_1.join_chat_button.click() group_chat_1.send_message(group_chat_message) if not group_chat_2.chat_element_by_text(group_chat_message).member_photo.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('User profile picture was not updated in message Group chat view') profile_1.just_fyi('Check profile image updated in on login view') home_1.profile_button.click() profile_1.logout() sign_in_1 = home_1.get_sign_in_view() if not sign_in_1.get_multiaccount_by_position(1).account_logo.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('User profile picture was not updated on Multiaccounts list select login view') sign_in_1.element_by_text(default_username_1).click() if not sign_in_1.get_multiaccount_by_position(1).account_logo.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('User profile picture was not updated on account login view') sign_in_1.password_input.set_value(common_password) sign_in_1.sign_in_button.click() profile_1.just_fyi('Remove user from contact and check there is no profile image displayed') group_chat_2.profile_button.click() profile_2.contacts_button.click() profile_2.element_by_text(default_username_1).click() one_to_one_chat_2.remove_from_contacts.click() # Send message to User 2 so update of profile image picked up group_chat_1 = home_1.get_chat('new_group_chat').click() group_chat_1.send_message(group_chat_message) one_to_one_chat_2.close_button.click() one_to_one_chat_2.home_button.click(desired_view='home') if home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('User profile picture is not default to default after user removed from Contacts') profile_2.just_fyi('Enable to see profile image from "Everyone" setting') home_2.profile_button.click() profile_2.appearance_button.click() profile_2.show_profile_pictures_of.click() profile_2.element_by_text('Everyone').click() group_chat_1.send_message(group_chat_message) profile_2.home_button.click(desired_view='home') if not home_2.get_chat(default_username_1).chat_image.is_element_image_similar_to_template('sauce_logo.png'): self.errors.append('User profile picture is not returned to default after user removed from Contacts') self.errors.verify_no_errors() @marks.testrail_id(5432) @marks.medium def test_custom_bootnodes(self): self.create_drivers(2) home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user() public_key = home_2.get_public_key_and_username() profile_1, profile_2 = home_1.profile_button.click(), home_2.profile_button.click() username_1, username_2 = profile_1.default_username_text.text, profile_2.default_username_text.text profile_1.just_fyi('Add custom bootnode, enable bootnodes and check validation') profile_1.advanced_button.click() profile_1.bootnodes_button.click() profile_1.add_bootnode_button.click() profile_1.specify_name_input.set_value('test') profile_1.bootnode_address_input.set_value('invalid_bootnode_address') if not profile_1.element_by_text_part('Invalid format').is_element_displayed(): self.errors.append('Validation message about invalid format of bootnode is not shown') profile_1.save_button.click() if profile_1.add_bootnode_button.is_element_displayed(): self.errors.append('User was navigated to another screen when tapped on disabled "Save" button') profile_1.bootnode_address_input.clear() profile_1.bootnode_address_input.set_value(bootnode_address) profile_1.save_button.click() profile_1.enable_bootnodes.click() profile_1.home_button.click() profile_1.just_fyi('Add contact and send first message') chat_1 = home_1.add_contact(public_key) message = 'test message' chat_1.chat_message_input.send_keys(message) chat_1.send_message_button.click() profile_2.home_button.click() chat_2 = home_2.get_chat(username_1).click() chat_2.chat_element_by_text(message).wait_for_visibility_of_element() chat_2.add_to_contacts.click() profile_1.just_fyi('Disable custom bootnodes') chat_1.profile_button.click() profile_1.advanced_button.click() profile_1.bootnodes_button.click() profile_1.enable_bootnodes.click() profile_1.home_button.click() profile_1.just_fyi('Send message and check that it is received after disabling bootnodes') home_1.get_chat(username_2).click() message_1 = 'new message' chat_1.chat_message_input.send_keys(message_1) chat_1.send_message_button.click() for chat in chat_1, chat_2: if not chat.chat_element_by_text(message_1).is_element_displayed(): self.errors.append('Message was not received after enabling bootnodes!') self.errors.verify_no_errors() @marks.testrail_id(5436) @marks.medium @marks.flaky def test_add_switch_delete_custom_mailserver(self): self.create_drivers(2) sign_in_1, sign_in_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) home_1, home_2 = sign_in_1.create_user(), sign_in_2.create_user() public_key = home_2.get_public_key_and_username() home_2.home_button.click() profile_1 = home_1.profile_button.click() username_1 = profile_1.default_username_text.text profile_1.just_fyi('disable autoselection') profile_1.sync_settings_button.click() profile_1.mail_server_button.click() mailserver = profile_1.return_mailserver_name(mailserver_hk, used_fleet) profile_1.mail_server_auto_selection_button.click() profile_1.mail_server_by_name(mailserver).click() profile_1.confirm_button.click() profile_1.just_fyi('add custom mailserver (check address/name validation) and connect to it') profile_1.plus_button.click() server_name = 'test' profile_1.save_button.click() if profile_1.element_by_text(mailserver).is_element_displayed(): self.errors.append('Could add custom mailserver with empty address and name') profile_1.specify_name_input.set_value(server_name) profile_1.mail_server_address_input.set_value(mailserver_address[:-3]) profile_1.save_button.click() if not profile_1.element_by_text_part("Invalid format").is_element_displayed(): self.errors.append('could add custom mailserver with invalid address') profile_1.mail_server_address_input.clear() profile_1.mail_server_address_input.set_value(mailserver_address) profile_1.save_button.click() profile_1.mail_server_by_name(server_name).click() profile_1.mail_server_connect_button.click() profile_1.confirm_button.click() if profile_1.element_by_text_part("Error connecting").is_element_displayed(40): profile_1.retry_to_connect_to_mailserver() profile_1.get_back_to_home_view() profile_1.home_button.click() profile_1.just_fyi('start chat with user2 and check that all messages are delivered') chat_1 = home_1.add_contact(public_key) message = 'test message' chat_1.chat_message_input.send_keys(message) chat_1.send_message_button.click() chat_2 = home_2.get_chat(username_1).click() chat_2.chat_element_by_text(message).wait_for_visibility_of_element() message_1 = 'new message' chat_2.chat_message_input.send_keys(message_1) chat_2.send_message_button.click() chat_1.chat_element_by_text(message_1).wait_for_visibility_of_element() profile_1.just_fyi('delete custom mailserver') chat_1.profile_button.click() profile_1.sync_settings_button.click() profile_1.mail_server_button.click() profile_1.element_by_text(mailserver).scroll_to_element() profile_1.element_by_text(mailserver).click() profile_1.confirm_button.click() profile_1.element_by_text(server_name).scroll_to_element() profile_1.element_by_text(server_name).click() profile_1.mail_server_delete_button.scroll_to_element() profile_1.mail_server_delete_button.click() profile_1.mail_server_confirm_delete_button.click() if profile_1.element_by_text(server_name).is_element_displayed(): self.errors.append('Deleted custom mailserver is shown') profile_1.get_back_to_home_view() profile_1.relogin() chat_1.profile_button.click() profile_1.sync_settings_button.click() profile_1.mail_server_button.click() if profile_1.element_by_text(server_name).is_element_displayed(): self.errors.append('Deleted custom mailserver is shown after relogin') self.errors.verify_no_errors() @marks.testrail_id(5767) @marks.medium @marks.flaky def test_can_not_connect_to_mailserver(self): self.create_drivers(2) home_1, home_2= SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user() profile_1 = home_1.profile_button.click() profile_1.just_fyi('add non-working mailserver and connect to it') profile_1.sync_settings_button.click() profile_1.mail_server_button.click() profile_1.mail_server_auto_selection_button.click() profile_1.plus_button.click() server_name = 'test' profile_1.specify_name_input.set_value(server_name) profile_1.mail_server_address_input.set_value(mailserver_address.replace('4','5')) profile_1.save_button.click() profile_1.mail_server_by_name(server_name).click() profile_1.mail_server_connect_button.click() profile_1.confirm_button.click() profile_1.just_fyi('check that popup "Error connecting" will not reappear if tap on "Cancel"') profile_1.element_by_translation_id(id='mailserver-error-title').wait_for_element(60) profile_1.cancel_button.click() profile_1.home_button.click() home_2.just_fyi('send several messages to public channel') public_chat_name = home_2.get_random_chat_name() message = 'test_message' public_chat_2 = home_2.join_public_chat(public_chat_name) public_chat_2.chat_message_input.send_keys(message) public_chat_2.send_message_button.click() public_chat_2.back_button.click() profile_1.just_fyi('join same public chat and try to reconnect via "Tap to reconnect" and check "Connecting"') profile_1.home_button.click() public_chat_1 = home_1.join_public_chat(public_chat_name) public_chat_1.relogin() profile_1.just_fyi('check that still connected to custom mailserver after relogin') home_1.profile_button.click() profile_1.sync_settings_button.click() if not profile_1.element_by_text(server_name).is_element_displayed(): self.drivers[0].fail("Not connected to custom mailserver after re-login") profile_1.just_fyi('check that can RETRY to connect') profile_1.element_by_translation_id(id='mailserver-error-title').wait_for_element(60) public_chat_1.element_by_translation_id(id='mailserver-retry', uppercase=True).wait_and_click(60) profile_1.just_fyi('check that can pick another mailserver and receive messages') profile_1.element_by_translation_id(id='mailserver-error-title').wait_for_element(60) profile_1.element_by_translation_id(id='mailserver-pick-another', uppercase=True).wait_and_click(120) mailserver = profile_1.return_mailserver_name(mailserver_ams, used_fleet) profile_1.element_by_text(mailserver).click() profile_1.confirm_button.click() profile_1.home_button.click() home_1.get_chat('#%s' % public_chat_name).click() if not public_chat_1.chat_element_by_text(message).is_element_displayed(60): self.errors.append("Chat history wasn't fetched") self.errors.verify_no_errors() @marks.testrail_id(6332) @marks.medium def test_disable_use_history_node(self): self.create_drivers(2) home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user() profile_1 = home_1.profile_button.click() home_2.just_fyi('send several messages to public channel') public_chat_name = home_2.get_random_chat_name() message, message_no_history = 'test_message', 'history node is disabled' public_chat_2 = home_2.join_public_chat(public_chat_name) public_chat_2.send_message(message) profile_1.just_fyi('disable use_history_node and check that no history is fetched but you can still send messages') profile_1.sync_settings_button.click() profile_1.mail_server_button.click() profile_1.use_history_node_button.click() profile_1.home_button.click() public_chat_1 = home_1.join_public_chat(public_chat_name) if public_chat_1.chat_element_by_text(message).is_element_displayed(30): self.errors.append('Chat history was fetched when use_history_node is disabled') public_chat_1.send_message(message_no_history) if not public_chat_2.chat_element_by_text(message_no_history).is_element_displayed(30): self.errors.append('Message sent when use_history_node is disabled was not received') public_chat_1.profile_button.click() profile_1.relogin() home_1.get_chat('#%s'%public_chat_name).click() if public_chat_1.chat_element_by_text(message).is_element_displayed(30): self.drivers[0].fail('History was fetched after relogin when use_history_node is disabled') profile_1.just_fyi('enable use_history_node and check that history is fetched') home_1.profile_button.click() profile_1.sync_settings_button.click() profile_1.mail_server_button.click() profile_1.use_history_node_button.click() profile_1.home_button.click(desired_view='chat') if not public_chat_1.chat_element_by_text(message).is_element_displayed(30): self.errors.append('History was not fetched after enabling use_history_node') self.errors.verify_no_errors() @marks.testrail_id(5762) @marks.high def test_pair_devices_sync_one_to_one_contacts_nicknames_public_chat(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) device_1_home = device_1.create_user() device_1_home.profile_button.click() device_1_profile = device_1_home.get_profile_view() device_1_profile.privacy_and_security_button.click() device_1_profile.backup_recovery_phrase_button.click() device_1_profile.ok_continue_button.click() recovery_phrase = device_1_profile.get_recovery_phrase() device_1_profile.close_button.click() device_1_profile.home_button.click() device_1_name = 'device_%s' % device_1.driver.number device_2_name = 'device_%s' % device_2.driver.number message_before_sync = 'sent before sync' message_after_sync = 'sent after sync' public_chat_before_sync = 'before-pairing' public_chat_after_sync = 'after-pairing' device_1.just_fyi('add contact, start 1-1 chat with basic user') device_1_chat = device_1_home.add_contact(basic_user['public_key']) device_1_chat.chat_message_input.send_keys(message_before_sync) device_1_chat.send_message_button.click() device_1.just_fyi('join public chat') device_1_chat.get_back_to_home_view() device_1_public_chat = device_1_home.join_public_chat(public_chat_before_sync) device_2_home = device_2.recover_access(passphrase=' '.join(recovery_phrase.values())) device_1_profile, device_2_profile = device_1_home.profile_button.click(), device_2_home.profile_button.click() device_2.just_fyi('go to profile and set nickname for contact') device_1_profile.open_contact_from_profile(basic_user['username']) nickname = 'my_basic_user' device_1_chat.set_nickname(nickname) device_1_profile.close_button.click() device_1.back_button.click() device_2.just_fyi('go to profile > Devices, set device name, discover device 2 to device 1') device_2_profile.discover_and_advertise_device(device_2_name) device_1_profile.discover_and_advertise_device(device_1_name) device_1_profile.get_toggle_device_by_name(device_2_name).wait_and_click() device_1_profile.sync_all_button.click() device_1_profile.sync_all_button.wait_for_visibility_of_element(15) [device.profile_button.click() for device in (device_1_profile, device_2_profile)] device_2.just_fyi('check that contact with nickname is appeared in Contact list') device_2_profile.contacts_button.scroll_to_element(9, 'up') device_2_profile.contacts_button.click() for name in (basic_user['username'], nickname): if not device_2_profile.element_by_text(name).is_element_displayed(): self.errors.append('"%s" is not found in Contacts after initial sync' % name) device_1.just_fyi('send message to 1-1 chat with basic user and add another contact') device_1_profile.home_button.click(desired_view='chat') device_1_public_chat.back_button.click() device_1_home.get_chat(nickname).click() device_1_chat.chat_message_input.send_keys(message_after_sync) device_1_chat.send_message_button.click() device_1_chat.back_button.click() device_1_home.add_contact(transaction_senders['A']['public_key']) device_2.just_fyi('check that messages appeared in 1-1 chat, public chats and new contacts are synced') if not device_2_profile.element_by_text(transaction_senders['A']['username']).is_element_displayed(60): self.errors.append( '"%s" is not found in Contacts after adding when devices are paired' % transaction_senders['A'][ 'username']) device_1.just_fyi('Set nickname for added contact and check that it will be synced') device_1_home.profile_button.click() device_1_profile.contacts_button.scroll_to_element(9, 'up') device_1_profile.open_contact_from_profile(transaction_senders['A']['username']) nickname_after_sync = 'my_transaction sender' device_1_chat.set_nickname(nickname_after_sync) device_1_profile.close_button.click() device_1.home_button.click(desired_view='chat') if not device_2_profile.element_by_text(nickname_after_sync).is_element_displayed(60): self.errors.append( '"%s" is not updated in Contacts after setting nickname when devices are paired' % nickname_after_sync) device_2_profile.home_button.click() if not device_2_home.element_by_text_part(public_chat_before_sync).is_element_displayed(): self.errors.append( '"%s" is not found in Home after initial sync when devices are paired' % public_chat_before_sync) chat = device_2_home.get_chat(nickname).click() if chat.chat_element_by_text(message_before_sync).is_element_displayed(): self.errors.append('"%s" message sent before pairing is synced' % message_before_sync) if not chat.chat_element_by_text(message_after_sync).is_element_displayed(60): self.errors.append('"%s" message in 1-1 is not synced' % message_after_sync) device_1.just_fyi('add new public chat and check that it will be synced with device2') device_1_chat.get_back_to_home_view() device_1_home.join_public_chat(public_chat_after_sync) device_2_home = chat.get_back_to_home_view() if not device_2_home.element_by_text_part(public_chat_after_sync).is_element_displayed(20): self.errors.append( '"%s" public chat is not synced after adding when devices are paired' % public_chat_after_sync) self.errors.verify_no_errors() @marks.testrail_id(6226) @marks.critical def test_ens_mentions_pn_and_nickname_in_public_and_1_1_chats(self): self.create_drivers(2) device_1, device_2 = self.drivers[0], self.drivers[1] sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2) user_1 = ens_user home_1 = sign_in_1.recover_access(user_1['passphrase'], enable_notifications=True) home_2 = sign_in_2.create_user() publuc_key_2, username_2 = home_2.get_public_key_and_username(return_username=True) home_2.home_button.double_click() home_1.just_fyi('switching to mainnet and add ENS') profile_1 = sign_in_1.profile_button.click() profile_1.switch_network('Mainnet with upstream RPC') home_1.profile_button.click() dapp_view_1 = profile_1.ens_usernames_button.click() dapp_view_1.element_by_text('Get started').click() dapp_view_1.ens_name_input.set_value(ens_user['ens']) expected_text = 'This user name is owned by you and connected with your chat key.' if not dapp_view_1.element_by_text_part(expected_text).is_element_displayed(): dapp_view_1.click_system_back_button() dapp_view_1.wait_for_element_starts_with_text(expected_text) dapp_view_1.check_ens_name.click_until_presence_of_element(dapp_view_1.element_by_text('Ok, got it')) dapp_view_1.element_by_text('Ok, got it').click() home_1.just_fyi('check ENS name wallet address and public key') profile_1.element_by_text(user_1['ens']).click() for text in ('10 SNT, deposit unlocked', user_1['address'].lower(), user_1['public_key'] ): if not profile_1.element_by_text_part(text).is_element_displayed(40): self.errors.append('%s text is not shown' % text) profile_1.home_button.click() home_2.just_fyi('joining same public chat, set ENS name and check it in chat from device2') chat_name = home_1.get_random_chat_name() chat_2 = home_2.join_public_chat(chat_name) chat_1 = home_1.join_public_chat(chat_name) chat_1.get_back_to_home_view() home_1.profile_button.click() ens_name = '@' + user_1['ens'] profile_1.element_by_text('Your ENS name').click() if profile_1.username_in_ens_chat_settings_text.text != ens_name: self.errors.append('ENS username is not shown in ENS usernames Chat Settings after enabling') profile_1.back_button.click() profile_1.home_button.click() home_1.get_chat('#' + chat_name).click() message_text_2 = 'message test text 1' chat_1.send_message(message_text_2) if not chat_2.wait_for_element_starts_with_text(ens_name): self.errors.append('ENS username is not shown in public chat') home_1.put_app_to_background() home_2.just_fyi('check that can mention user with ENS name') chat_2.select_mention_from_suggestion_list(user_1['ens']) if chat_2.chat_message_input.text != ens_name + ' ': self.errors.append('ENS username is not resolved in chat input after selecting it in mention suggestions list!') chat_2.send_message_button.click() chat_2.element_starts_with_text(ens_name,'button').click() for element in (chat_2.element_by_text(user_1['username']), chat_2.profile_add_to_contacts): if not element.is_element_displayed(): self.errors.append('Was not redirected to user profile after tapping on mention!') home_1.just_fyi('check that PN is received and after tap you are redirected to public chat, mention is highligted') home_1.open_notification_bar() home_1.element_by_text_part(username_2).click() if home_1.element_starts_with_text(user_1['ens'] +'.stateofus.eth').is_element_differs_from_template('mentioned.png', 2): self.errors.append('Mention is not highlighted!') # Close Device1 driver session since it's not needed anymore self.drivers[0].quit() home_2.just_fyi('check that ENS name is shown in 1-1 chat without adding user as contact in header, profile, options') chat_2_one_to_one = chat_2.profile_send_message.click() if chat_2_one_to_one.user_name_text.text != ens_name: self.errors.append('ENS username is not shown in 1-1 chat header') chat_2_one_to_one.chat_options.click() if not chat_2_one_to_one.element_by_text(ens_name).is_element_displayed(): self.errors.append('ENS username is not shown in 1-1 chat options') chat_2_one_to_one.view_profile_button.click() if not chat_2_one_to_one.element_by_text(ens_name).is_element_displayed(): self.errors.append('ENS username is not shown in user profile') home_2.just_fyi('add user to contacts and check that ENS name is shown in contact') chat_2_one_to_one.profile_add_to_contacts.click() chat_2.close_button.click() profile_2 = chat_2_one_to_one.profile_button.click() profile_2.open_contact_from_profile(ens_name) home_2.just_fyi('set nickname and recheck username in 1-1 header, profile, options, contacts') nickname = 'test user' + str(round(time())) chat_2.set_nickname(nickname) profile_2.close_button.click() for name in (nickname, ens_name): if not profile_2.element_by_text(name).is_element_displayed(): self.errors.append('%s is not shown in contact list' % name) profile_2.home_button.click(desired_view='chat') if chat_2_one_to_one.user_name_text.text != nickname: self.errors.append('Nickname for user with ENS is not shown in 1-1 chat header') chat_2_one_to_one.chat_options.click() if not chat_2_one_to_one.element_by_text(nickname).is_element_displayed(): self.errors.append('Nickname for user with ENS is not shown in 1-1 chat options') home_2.just_fyi('check nickname in public chat') chat_2.get_back_to_home_view() home_2.get_chat('#' + chat_name).click() chat_element = chat_2.chat_element_by_text(message_text_2) chat_element.find_element() if chat_element.username.text != '%s %s' % (nickname, ens_name): self.errors.append('Nickname for user with ENS is not shown in public chat') self.errors.verify_no_errors() @marks.testrail_id(6228) @marks.high def test_mobile_data_usage_complex_settings(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) device_1_home = device_1.create_user() public_chat_name, public_chat_message = 'e2e-started-before', 'message to pub chat' device_1_public = device_1_home.join_public_chat(public_chat_name) device_1_public.send_message(public_chat_message) device_1_home.just_fyi('set mobile data to "OFF" and check that peer-to-peer connection is still working') device_2_home = device_2.create_user() device_2_home.toggle_mobile_data() device_2_home.mobile_connection_off_icon.wait_for_visibility_of_element(20) for element in device_2_home.continue_syncing_button, device_2_home.stop_syncing_button, device_2_home.remember_my_choice_checkbox: if not element.is_element_displayed(10): self.drivers[0].fail('Element %s is not not shown in "Syncing mobile" bottom sheet' % element.locator) device_2_home.stop_syncing_button.click() if not device_2_home.mobile_connection_off_icon.is_element_displayed(): self.drivers[0].fail('No mobile connection OFF icon is shown') device_2_home.mobile_connection_off_icon.click() for element in device_2_home.connected_to_n_peers_text, device_2_home.waiting_for_wi_fi: if not element.is_element_displayed(): self.errors.append("Element '%s' is not shown in Connection status bottom sheet" % element.locator) device_2_home.click_system_back_button() device_2_public = device_2_home.join_public_chat(public_chat_name) if device_2_public.chat_element_by_text(public_chat_message).is_element_displayed(30): self.errors.append("Chat history was fetched with mobile data fetching off") public_chat_new_message = 'new message' device_1_public.send_message(public_chat_new_message) if not device_2_public.chat_element_by_text(public_chat_new_message).is_element_displayed(30): self.errors.append("Peer-to-peer connection is not working when mobile data fetching is off") device_2_home.just_fyi('set mobile data to "ON"') device_2_home.home_button.click() device_2_home.mobile_connection_off_icon.click() device_2_home.use_mobile_data_switch.click() if not device_2_home.connected_to_node_text.is_element_displayed(10): self.errors.append("Not connected to history node after enabling fetching on mobile data") device_2_home.click_system_back_button() device_2_home.mobile_connection_on_icon.wait_for_visibility_of_element(10) if not device_2_home.mobile_connection_on_icon.is_element_displayed(): self.errors.append('No mobile connection ON icon is shown') device_2_home.get_chat('#%s'% public_chat_name).click() if not device_2_public.chat_element_by_text(public_chat_message).is_element_displayed(90): self.errors.append("Chat history was not fetched with mobile data fetching ON") device_2_home.just_fyi('check redirect to sync settings by tappin "Sync" in connection status bottom sheet') device_2_home.home_button.click() device_2_home.mobile_connection_on_icon.click() device_2_home.connection_settings_button.click() if not device_2_home.element_by_translation_id("mobile-network-use-mobile").is_element_displayed(): self.errors.append("Was not redirected to sync settings after tapping on Settings in connection bottom sheet") device_1_home.just_fyi("Check default preferences in Sync settings") device_1_profile = device_1_home.profile_button.click() device_1_profile.sync_settings_button.click() if not device_1_profile.element_by_translation_id("mobile-network-use-wifi").is_element_displayed(): self.errors.append("Mobile data is enabled by default") device_1_profile.element_by_translation_id("mobile-network-use-wifi").click() if device_1_profile.ask_me_when_on_mobile_network.text != "ON": self.errors.append("'Ask me when on mobile network' is not enabled by default") device_1_profile.just_fyi("Disable 'ask me when on mobile network' and check that it is not shown") device_1_profile.ask_me_when_on_mobile_network.click() device_1_profile.toggle_mobile_data() if device_1_profile.element_by_translation_id("mobile-network-start-syncing").is_element_displayed(20): self.errors.append("Popup is shown, but 'ask me when on mobile network' is disabled") device_1_profile.just_fyi("Check 'Restore default' setting") device_1_profile.element_by_text('Restore Defaults').click() if device_1_profile.use_mobile_data.attribute_value("checked"): self.errors.append("Mobile data is enabled by default") if not device_1_profile.ask_me_when_on_mobile_network.attribute_value("checked"): self.errors.append("'Ask me when on mobile network' is not enabled by default") self.errors.verify_no_errors() @marks.testrail_id(5680) @marks.high @marks.skip # TODO: skip until edit userpic is enabled back def test_pair_devices_sync_name_photo_public_group_chats(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) device_1_home = device_1.create_user() device_1_home.profile_button.click() device_1_profile = device_1_home.get_profile_view() device_1_profile.privacy_and_security_button.click() device_1_profile.backup_recovery_phrase_button.click() recovery_phrase = device_1_profile.backup_recovery_phrase() device_1_profile.back_button.click() device_1_profile.get_back_to_home_view() device_1_name = 'device_%s' % device_1.driver.number device_2_name = 'device_%s' % device_2.driver.number public_chat_before_sync_name = 'b-public-%s' % device_1_home.get_random_chat_name() public_chat_after_sync_name = 'a-public-%s' % device_1_home.get_random_chat_name() group_chat_name = 'group-%s' % device_1_home.get_random_chat_name() message_after_sync = 'sent after sync' device_1.just_fyi('join public chat, create group chat, edit user picture') device_1_public_chat = device_1_home.join_public_chat(public_chat_before_sync_name) device_1_public_chat.back_button.click() device_1_one_to_one = device_1_home.add_contact(basic_user['public_key']) device_1_one_to_one.back_button.click() device_1_group_chat = device_1_home.create_group_chat([basic_user['username']], group_chat_name) device_1_group_chat.back_button.click() device_1_home.profile_button.click() device_1_profile = device_1_home.get_profile_view() device_1_profile.edit_profile_picture('sauce_logo.png') device_2.just_fyi('go to profile > Devices, set device name, discover device 2 to device 1') device_2_home = device_2.recover_access(passphrase=' '.join(recovery_phrase.values())) device_2_profile = device_2_home.get_profile_view() device_2_profile.discover_and_advertise_device(device_2_name) device_1.just_fyi('enable pairing of `device 2` and sync') device_1_profile.discover_and_advertise_device(device_1_name) device_1_profile.get_toggle_device_by_name(device_2_name).click() device_1_profile.sync_all_button.click() device_1_profile.sync_all_button.wait_for_visibility_of_element(15) device_2.just_fyi('check that public chat and profile details are updated') device_2_home = device_2_profile.home_button.click() if not device_2_home.element_by_text('#%s' % public_chat_before_sync_name).is_element_displayed(): self.errors.append('Public chat "%s" doesn\'t appear after initial sync' % public_chat_before_sync_name) device_2_home.home_button.click() device_2_home.profile_button.click() if not device_2_profile.profile_picture.is_element_image_equals_template('sauce_logo_profile.png'): self.errors.append('Profile picture was not updated after initial sync') device_2_profile.home_button.click() device_1.just_fyi('send message to group chat, and join to new public chat') device_1_home = device_1_profile.home_button.click() device_1_public_chat = device_1_home.join_public_chat(public_chat_after_sync_name) device_1_public_chat.back_button.click() device_1_home.element_by_text(group_chat_name).click() device_1_group_chat.chat_message_input.send_keys(message_after_sync) device_1_group_chat.send_message_button.click() device_1_group_chat.back_button.click() device_2.just_fyi('check that message in group chat is shown, public chats are synced') if not device_2_home.element_by_text('#%s' % public_chat_after_sync_name).is_element_displayed(): self.errors.append('Public chat "%s" doesn\'t appear on other device when devices are paired' % public_chat_before_sync_name) device_2_home.element_by_text(group_chat_name).click() device_2_group_chat = device_2_home.get_chat_view() if not device_2_group_chat.chat_element_by_text(message_after_sync).is_element_displayed(): self.errors.append('"%s" message in group chat is not synced' % message_after_sync) self.errors.verify_no_errors()
mpl-2.0
[ 646, 295, 199, 199, 504, 2295, 492, 17370, 12, 8498, 932, 63, 1562, 12, 6016, 1000, 63, 1562, 12, 511, 63, 68, 571, 63, 633, 12, 511, 63, 68, 571, 63, 354, 12, 6016, 1000, 63, 19470, 12, 971, 272, 6016, 1000, 63, 9493, 12, 6016, 1000, 63, 21557, 12, 1202, 63, 21599, 386, 12, 2863, 63, 2060, 199, 504, 2295, 14, 1095, 63, 396, 63, 2546, 492, 13050, 2510, 1746, 12, 14326, 2510, 1746, 199, 504, 2295, 14, 3707, 492, 6008, 63, 2464, 7735, 12, 5678, 63, 751, 12, 12889, 63, 751, 12, 12889, 63, 751, 63, 26307, 724, 199, 504, 6858, 14, 1037, 63, 262, 63, 1345, 492, 6632, 607, 2768, 199, 504, 900, 492, 900, 421, 199, 533, 1379, 5736, 7200, 2510, 8, 7200, 2510, 1746, 304, 339, 768, 10375, 14, 396, 345, 382, 63, 344, 8, 2766, 1085, 9, 272, 768, 10375, 14, 14345, 272, 347, 511, 63, 2425, 63, 1807, 63, 261, 422, 279, 63, 3029, 8370, 8, 277, 304, 267, 2070, 63, 262, 275, 6632, 607, 2768, 8, 277, 14, 3090, 9, 267, 2070, 63, 262, 14, 981, 63, 751, 342, 267, 3145, 63, 9241, 63, 3764, 275, 2070, 63, 262, 14, 362, 63, 6893, 63, 991, 63, 498, 480, 1807, 13, 2913, 13, 3764, 531, 267, 4690, 275, 2070, 63, 262, 14, 2913, 63, 3887, 14, 4891, 342, 267, 4690, 14, 11646, 342, 267, 340, 2070, 63, 262, 14, 745, 63, 3887, 14, 374, 63, 2108, 63, 22283, 837, 288, 2070, 63, 262, 14, 745, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 894, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 12695, 63, 1612, 63, 6878, 63, 4677, 14, 4891, 342, 267, 2070, 63, 262, 14, 4208, 63, 1222, 63, 498, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 981, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 9548, 63, 12695, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 11853, 63, 18103, 63, 3887, 14, 4891, 63, 8111, 63, 21566, 63, 1618, 63, 2108, 8, 1037, 63, 262, 14, 16537, 63, 1939, 63, 3887, 9, 267, 2070, 63, 262, 14, 16537, 63, 1939, 63, 3887, 14, 4891, 342, 398, 2070, 63, 262, 14, 4764, 63, 1399, 73, 360, 5392, 499, 977, 3510, 2048, 358, 267, 4575, 63, 498, 12, 3434, 275, 2070, 63, 262, 14, 362, 63, 3455, 63, 498, 63, 460, 63, 2473, 8, 1107, 63, 2473, 29, 549, 9, 267, 4690, 14, 17258, 63, 460, 63, 4416, 63, 3887, 14, 4891, 342, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 3887, 14, 6755, 63, 460, 63, 4891, 342, 267, 367, 1318, 315, 334, 2473, 12, 3145, 63, 9241, 63, 3764, 304, 288, 340, 440, 4690, 14, 2108, 63, 991, 63, 505, 8, 505, 680, 374, 63, 2108, 63, 22283, 837, 355, 291, 14, 2550, 14, 740, 360, 8030, 450, 83, 365, 440, 9164, 1380, 13794, 3510, 2048, 7, 450, 1318, 9, 267, 4690, 14, 1807, 63, 2913, 63, 3887, 14, 4891, 342, 267, 340, 4690, 14, 2108, 63, 991, 63, 6893, 63, 344, 480, 2913, 13, 6062, 13, 1213, 3471, 374, 63, 2108, 63, 22283, 837, 288, 291, 14, 3090, 14, 1633, 360, 5736, 365, 5463, 1928, 18791, 543, 2505, 358, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 4690, 14, 1807, 63, 2913, 63, 3887, 14, 4891, 63, 8111, 63, 21566, 63, 1618, 63, 2108, 8, 2913, 14, 2108, 63, 991, 63, 6893, 63, 344, 480, 2913, 13, 6062, 13, 1213, 2237, 267, 4690, 14, 745, 63, 3887, 14, 4891, 342, 398, 2070, 63, 262, 14, 4764, 63, 1399, 73, 360, 5392, 2061, 3510, 2048, 358, 267, 2070, 63, 262, 14, 1037, 63, 262, 342, 267, 2070, 63, 262, 14, 2913, 63, 3887, 14, 4891, 342, 267, 4690, 14, 17258, 63, 460, 63, 4416, 63, 3887, 14, 4891, 342, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 3887, 14, 6755, 63, 460, 63, 4891, 342, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 4690, 14, 1807, 63, 2913, 63, 3887, 14, 4891, 342, 267, 4690, 14, 745, 63, 3887, 14, 4891, 342, 267, 340, 440, 2070, 63, 262, 14, 362, 63, 8924, 63, 3887, 14, 374, 63, 2108, 63, 22283, 8, 1165, 304, 288, 291, 14, 2550, 14, 740, 360, 1944, 20884, 370, 9590, 810, 5891, 2455, 2410, 13794, 2061, 3510, 2048, 358, 267, 291, 14, 2550, 14, 4712, 63, 889, 63, 2550, 342, 339, 768, 10375, 14, 396, 345, 382, 63, 344, 8, 21, 13905, 9, 272, 768, 10375, 14, 13138, 272, 347, 511, 63, 6251, 63, 1574, 63, 7811, 63, 600, 63, 460, 63, 13892, 63, 1562, 8, 277, 304, 267, 5629, 275, 6632, 607, 2768, 8, 277, 14, 3090, 680, 981, 63, 751, 342, 267, 4690, 275, 5629, 14, 2913, 63, 3887, 14, 4891, 342, 398, 5629, 14, 4764, 63, 1399, 73, 480, 32596, 8966, 1233, 531, 267, 4690, 14, 6251, 63, 1662, 63, 2913, 63, 3887, 14, 4891, 342, 267, 4575, 63, 498, 275, 4690, 14, 3455, 63, 498, 63, 505, 14, 505, 267, 4690, 14, 3455, 63, 498, 63, 505, 14, 2809, 63, 2915, 63, 2108, 342, 267, 4690, 14, 1574, 63, 505, 342, 398, 5629, 14, 4764, 63, 1399, 73, 480, 2662, 9332, 8966, 1233, 4799, 26560, 23444, 531, 267, 4690, 14, 6251, 63, 3887, 14, 4891, 342, 267, 4690, 14, 6251, 63, 12897, 63, 6415, 23444, 342, 267, 340, 440, 4690, 14, 2108, 63, 991, 63, 505, 63, 2064, 8, 3455, 63, 498, 680, 374, 63, 2108, 63, 1881, 837, 288, 291, 14, 2550, 14, 740, 480, 6049, 1133, 8663, 4575, 790, 531, 267, 359, 2913 ]
[ 295, 199, 199, 504, 2295, 492, 17370, 12, 8498, 932, 63, 1562, 12, 6016, 1000, 63, 1562, 12, 511, 63, 68, 571, 63, 633, 12, 511, 63, 68, 571, 63, 354, 12, 6016, 1000, 63, 19470, 12, 971, 272, 6016, 1000, 63, 9493, 12, 6016, 1000, 63, 21557, 12, 1202, 63, 21599, 386, 12, 2863, 63, 2060, 199, 504, 2295, 14, 1095, 63, 396, 63, 2546, 492, 13050, 2510, 1746, 12, 14326, 2510, 1746, 199, 504, 2295, 14, 3707, 492, 6008, 63, 2464, 7735, 12, 5678, 63, 751, 12, 12889, 63, 751, 12, 12889, 63, 751, 63, 26307, 724, 199, 504, 6858, 14, 1037, 63, 262, 63, 1345, 492, 6632, 607, 2768, 199, 504, 900, 492, 900, 421, 199, 533, 1379, 5736, 7200, 2510, 8, 7200, 2510, 1746, 304, 339, 768, 10375, 14, 396, 345, 382, 63, 344, 8, 2766, 1085, 9, 272, 768, 10375, 14, 14345, 272, 347, 511, 63, 2425, 63, 1807, 63, 261, 422, 279, 63, 3029, 8370, 8, 277, 304, 267, 2070, 63, 262, 275, 6632, 607, 2768, 8, 277, 14, 3090, 9, 267, 2070, 63, 262, 14, 981, 63, 751, 342, 267, 3145, 63, 9241, 63, 3764, 275, 2070, 63, 262, 14, 362, 63, 6893, 63, 991, 63, 498, 480, 1807, 13, 2913, 13, 3764, 531, 267, 4690, 275, 2070, 63, 262, 14, 2913, 63, 3887, 14, 4891, 342, 267, 4690, 14, 11646, 342, 267, 340, 2070, 63, 262, 14, 745, 63, 3887, 14, 374, 63, 2108, 63, 22283, 837, 288, 2070, 63, 262, 14, 745, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 894, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 12695, 63, 1612, 63, 6878, 63, 4677, 14, 4891, 342, 267, 2070, 63, 262, 14, 4208, 63, 1222, 63, 498, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 981, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 9548, 63, 12695, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 2070, 63, 262, 14, 2184, 63, 3887, 14, 4891, 342, 267, 2070, 63, 262, 14, 11853, 63, 18103, 63, 3887, 14, 4891, 63, 8111, 63, 21566, 63, 1618, 63, 2108, 8, 1037, 63, 262, 14, 16537, 63, 1939, 63, 3887, 9, 267, 2070, 63, 262, 14, 16537, 63, 1939, 63, 3887, 14, 4891, 342, 398, 2070, 63, 262, 14, 4764, 63, 1399, 73, 360, 5392, 499, 977, 3510, 2048, 358, 267, 4575, 63, 498, 12, 3434, 275, 2070, 63, 262, 14, 362, 63, 3455, 63, 498, 63, 460, 63, 2473, 8, 1107, 63, 2473, 29, 549, 9, 267, 4690, 14, 17258, 63, 460, 63, 4416, 63, 3887, 14, 4891, 342, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 3887, 14, 6755, 63, 460, 63, 4891, 342, 267, 367, 1318, 315, 334, 2473, 12, 3145, 63, 9241, 63, 3764, 304, 288, 340, 440, 4690, 14, 2108, 63, 991, 63, 505, 8, 505, 680, 374, 63, 2108, 63, 22283, 837, 355, 291, 14, 2550, 14, 740, 360, 8030, 450, 83, 365, 440, 9164, 1380, 13794, 3510, 2048, 7, 450, 1318, 9, 267, 4690, 14, 1807, 63, 2913, 63, 3887, 14, 4891, 342, 267, 340, 4690, 14, 2108, 63, 991, 63, 6893, 63, 344, 480, 2913, 13, 6062, 13, 1213, 3471, 374, 63, 2108, 63, 22283, 837, 288, 291, 14, 3090, 14, 1633, 360, 5736, 365, 5463, 1928, 18791, 543, 2505, 358, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 4690, 14, 1807, 63, 2913, 63, 3887, 14, 4891, 63, 8111, 63, 21566, 63, 1618, 63, 2108, 8, 2913, 14, 2108, 63, 991, 63, 6893, 63, 344, 480, 2913, 13, 6062, 13, 1213, 2237, 267, 4690, 14, 745, 63, 3887, 14, 4891, 342, 398, 2070, 63, 262, 14, 4764, 63, 1399, 73, 360, 5392, 2061, 3510, 2048, 358, 267, 2070, 63, 262, 14, 1037, 63, 262, 342, 267, 2070, 63, 262, 14, 2913, 63, 3887, 14, 4891, 342, 267, 4690, 14, 17258, 63, 460, 63, 4416, 63, 3887, 14, 4891, 342, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 3887, 14, 6755, 63, 460, 63, 4891, 342, 267, 4690, 14, 1807, 63, 1662, 63, 2913, 63, 2060, 63, 1210, 14, 409, 63, 585, 8, 2330, 63, 2060, 9, 267, 4690, 14, 1807, 63, 2913, 63, 3887, 14, 4891, 342, 267, 4690, 14, 745, 63, 3887, 14, 4891, 342, 267, 340, 440, 2070, 63, 262, 14, 362, 63, 8924, 63, 3887, 14, 374, 63, 2108, 63, 22283, 8, 1165, 304, 288, 291, 14, 2550, 14, 740, 360, 1944, 20884, 370, 9590, 810, 5891, 2455, 2410, 13794, 2061, 3510, 2048, 358, 267, 291, 14, 2550, 14, 4712, 63, 889, 63, 2550, 342, 339, 768, 10375, 14, 396, 345, 382, 63, 344, 8, 21, 13905, 9, 272, 768, 10375, 14, 13138, 272, 347, 511, 63, 6251, 63, 1574, 63, 7811, 63, 600, 63, 460, 63, 13892, 63, 1562, 8, 277, 304, 267, 5629, 275, 6632, 607, 2768, 8, 277, 14, 3090, 680, 981, 63, 751, 342, 267, 4690, 275, 5629, 14, 2913, 63, 3887, 14, 4891, 342, 398, 5629, 14, 4764, 63, 1399, 73, 480, 32596, 8966, 1233, 531, 267, 4690, 14, 6251, 63, 1662, 63, 2913, 63, 3887, 14, 4891, 342, 267, 4575, 63, 498, 275, 4690, 14, 3455, 63, 498, 63, 505, 14, 505, 267, 4690, 14, 3455, 63, 498, 63, 505, 14, 2809, 63, 2915, 63, 2108, 342, 267, 4690, 14, 1574, 63, 505, 342, 398, 5629, 14, 4764, 63, 1399, 73, 480, 2662, 9332, 8966, 1233, 4799, 26560, 23444, 531, 267, 4690, 14, 6251, 63, 3887, 14, 4891, 342, 267, 4690, 14, 6251, 63, 12897, 63, 6415, 23444, 342, 267, 340, 440, 4690, 14, 2108, 63, 991, 63, 505, 63, 2064, 8, 3455, 63, 498, 680, 374, 63, 2108, 63, 1881, 837, 288, 291, 14, 2550, 14, 740, 480, 6049, 1133, 8663, 4575, 790, 531, 267, 359, 2913, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ttthy1/2017sejongAI
week14/Mnist.py
1
2273
# Lab 7 Learning rate and Evaluation import tensorflow as tf import random import matplotlib.pyplot as plt tf.set_random_seed(777) # for reproducibility from tensorflow.examples.tutorials.mnist import input_data # Check out https://www.tensorflow.org/get_started/mnist/beginners for # more information about the mnist dataset mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) nb_classes = 10 # MNIST data image of shape 28 * 28 = 784 X = tf.placeholder(tf.float32, [None, 784]) # 0 - 9 digits recognition = 10 classes Y = tf.placeholder(tf.float32, [None, nb_classes]) W = tf.Variable(tf.random_normal([784, nb_classes])) b = tf.Variable(tf.random_normal([nb_classes])) # Hypothesis (using softmax) hypothesis = tf.nn.softmax(tf.matmul(X, W) + b) cost = tf.reduce_mean(-tf.reduce_sum(Y * tf.log(hypothesis), axis=1)) optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1).minimize(cost) # Test model is_correct = tf.equal(tf.arg_max(hypothesis, 1), tf.arg_max(Y, 1)) # Calculate accuracy accuracy = tf.reduce_mean(tf.cast(is_correct, tf.float32)) # parameters training_epochs = 15 batch_size = 100 with tf.Session() as sess: # Initialize TensorFlow variables sess.run(tf.global_variables_initializer()) # Training cycle for epoch in range(training_epochs): avg_cost = 0 total_batch = int(mnist.train.num_examples / batch_size) for i in range(total_batch): batch_xs, batch_ys = mnist.train.next_batch(batch_size) c, _ = sess.run([cost, optimizer], feed_dict={ X: batch_xs, Y: batch_ys}) avg_cost += c / total_batch print('Epoch:', '%04d' % (epoch + 1), 'cost =', '{:.9f}'.format(avg_cost)) print("Learning finished") # Test the model using test sets print("Accuracy: ", accuracy.eval(session=sess, feed_dict={ X: mnist.test.images, Y: mnist.test.labels})) # Get one and predict r = random.randint(0, mnist.test.num_examples - 1) print("Label: ", sess.run(tf.argmax(mnist.test.labels[r:r + 1], 1))) print("Prediction: ", sess.run( tf.argmax(hypothesis, 1), feed_dict={X: mnist.test.images[r:r + 1]})) plt.imshow( mnist.test.images[r:r + 1].reshape(28, 28), cmap='Greys', interpolation='nearest') plt.show()
gpl-3.0
[ 3, 16871, 1520, 29127, 6634, 436, 16494, 4086, 199, 646, 3228, 465, 2833, 199, 646, 2196, 199, 646, 8027, 14, 13563, 465, 4488, 199, 3249, 14, 409, 63, 2355, 63, 5176, 8, 11956, 9, 327, 367, 295, 496, 2033, 559, 3195, 199, 199, 504, 3228, 14, 8589, 14, 23561, 83, 14, 32164, 492, 1324, 63, 576, 199, 3, 2670, 734, 4178, 921, 1544, 14, 16008, 14, 1308, 15, 362, 63, 8924, 15, 32164, 15, 5037, 8715, 367, 199, 3, 1655, 2556, 3595, 314, 21945, 631, 4789, 199, 32164, 275, 1324, 63, 576, 14, 739, 63, 576, 63, 2193, 480, 16237, 6225, 63, 576, 10665, 1373, 63, 8885, 29, 549, 9, 199, 199, 4994, 63, 2888, 275, 1616, 199, 199, 3, 603, 25392, 666, 1834, 402, 2215, 7294, 627, 7294, 275, 1520, 1349, 199, 56, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 1520, 1349, 566, 199, 3, 378, 446, 1749, 7576, 17319, 15415, 275, 1616, 3992, 199, 57, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 8526, 63, 2888, 566, 199, 199, 55, 275, 2833, 14, 2773, 8, 3249, 14, 2355, 63, 3302, 779, 28394, 12, 8526, 63, 2888, 2459, 199, 66, 275, 2833, 14, 2773, 8, 3249, 14, 2355, 63, 3302, 779, 4994, 63, 2888, 2459, 199, 199, 3, 29591, 555, 14925, 334, 4941, 28344, 9, 199, 3577, 555, 14925, 275, 2833, 14, 4411, 14, 16395, 8, 3249, 14, 14465, 8, 56, 12, 644, 9, 435, 330, 9, 199, 199, 6336, 275, 2833, 14, 5270, 63, 3670, 2801, 3249, 14, 5270, 63, 1838, 8, 57, 627, 2833, 14, 793, 8, 3577, 555, 14925, 395, 3114, 29, 17, 430, 199, 12290, 275, 2833, 14, 2834, 14, 9942, 26232, 13946, 8, 10546, 63, 1866, 29, 16, 14, 17, 680, 19333, 8, 6336, 9, 199, 199, 3, 1379, 1402, 199, 374, 63, 4525, 275, 2833, 14, 1452, 8, 3249, 14, 1273, 63, 988, 8, 3577, 555, 14925, 12, 413, 395, 2833, 14, 1273, 63, 988, 8, 57, 12, 413, 430, 199, 3, 12707, 12862, 199, 13374, 275, 2833, 14, 5270, 63, 3670, 8, 3249, 14, 2931, 8, 374, 63, 4525, 12, 2833, 14, 1609, 708, 430, 199, 199, 3, 2633, 199, 7588, 63, 13161, 275, 4114, 199, 2912, 63, 890, 275, 2948, 199, 199, 1045, 2833, 14, 4434, 342, 465, 4043, 26, 272, 327, 11578, 9134, 2860, 272, 4043, 14, 1065, 8, 3249, 14, 2966, 63, 3669, 63, 6498, 1012, 272, 327, 22859, 8643, 272, 367, 9463, 315, 1425, 8, 7588, 63, 13161, 304, 267, 12402, 63, 6336, 275, 378, 267, 3141, 63, 2912, 275, 1109, 8, 32164, 14, 2834, 14, 1507, 63, 8589, 1182, 3522, 63, 890, 9, 398, 367, 284, 315, 1425, 8, 2923, 63, 2912, 304, 288, 3522, 63, 7977, 12, 3522, 63, 588, 275, 21945, 631, 14, 2834, 14, 2184, 63, 2912, 8, 2912, 63, 890, 9, 288, 286, 12, 485, 275, 4043, 14, 1065, 779, 6336, 12, 10736, 467, 4733, 63, 807, 3126, 355, 1323, 26, 3522, 63, 7977, 12, 1488, 26, 3522, 63, 588, 1552, 288, 12402, 63, 6336, 847, 286, 1182, 3141, 63, 2912, 1467, 199, 1361, 360, 29322, 6536, 1543, 966, 68, 7, 450, 334, 7367, 435, 413, 395, 489, 283, 6336, 28414, 5041, 14010, 25, 70, 5285, 908, 8, 8595, 63, 6336, 430, 199, 199, 1361, 480, 25519, 9158, 531, 199, 199, 3, 1379, 314, 1402, 1808, 511, 5951, 199, 1361, 480, 1945, 7933, 26, 3872, 12862, 14, 2579, 8, 1730, 29, 5480, 12, 4733, 63, 807, 3126, 272, 1323, 26, 21945, 631, 14, 396, 14, 4782, 12, 1488, 26, 21945, 631, 14, 396, 14, 3512, 12466, 199, 199, 3, 2372, 1373, 436, 12610, 199, 82, 275, 2196, 14, 8393, 8, 16, 12, 21945, 631, 14, 396, 14, 1507, 63, 8589, 446, 413, 9, 199, 1361, 480, 4314, 26, 3872, 4043, 14, 1065, 8, 3249, 14, 16383, 8, 32164, 14, 396, 14, 3512, 59, 82, 26, 82, 435, 413, 467, 413, 1724, 199, 1361, 480, 24261, 26, 3872, 4043, 14, 1065, 8, 272, 2833, 14, 16383, 8, 3577, 555, 14925, 12, 413, 395, 4733, 63, 807, 3126, 56, 26, 21945, 631, 14, 396, 14, 4782, 59, 82, 26, 82, 435, 413, 9420, 430, 199, 199, 6003, 14, 20413, 8, 272, 21945, 631, 14, 396, 14, 4782, 59, 82, 26, 82, 435, 413, 1055, 5217, 8, 1651, 12, 7294, 395, 272, 14920, 534, 39, 264, 588, 297, 272, 14046, 534, 16615, 358, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 16871, 1520, 29127, 6634, 436, 16494, 4086, 199, 646, 3228, 465, 2833, 199, 646, 2196, 199, 646, 8027, 14, 13563, 465, 4488, 199, 3249, 14, 409, 63, 2355, 63, 5176, 8, 11956, 9, 327, 367, 295, 496, 2033, 559, 3195, 199, 199, 504, 3228, 14, 8589, 14, 23561, 83, 14, 32164, 492, 1324, 63, 576, 199, 3, 2670, 734, 4178, 921, 1544, 14, 16008, 14, 1308, 15, 362, 63, 8924, 15, 32164, 15, 5037, 8715, 367, 199, 3, 1655, 2556, 3595, 314, 21945, 631, 4789, 199, 32164, 275, 1324, 63, 576, 14, 739, 63, 576, 63, 2193, 480, 16237, 6225, 63, 576, 10665, 1373, 63, 8885, 29, 549, 9, 199, 199, 4994, 63, 2888, 275, 1616, 199, 199, 3, 603, 25392, 666, 1834, 402, 2215, 7294, 627, 7294, 275, 1520, 1349, 199, 56, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 1520, 1349, 566, 199, 3, 378, 446, 1749, 7576, 17319, 15415, 275, 1616, 3992, 199, 57, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 8526, 63, 2888, 566, 199, 199, 55, 275, 2833, 14, 2773, 8, 3249, 14, 2355, 63, 3302, 779, 28394, 12, 8526, 63, 2888, 2459, 199, 66, 275, 2833, 14, 2773, 8, 3249, 14, 2355, 63, 3302, 779, 4994, 63, 2888, 2459, 199, 199, 3, 29591, 555, 14925, 334, 4941, 28344, 9, 199, 3577, 555, 14925, 275, 2833, 14, 4411, 14, 16395, 8, 3249, 14, 14465, 8, 56, 12, 644, 9, 435, 330, 9, 199, 199, 6336, 275, 2833, 14, 5270, 63, 3670, 2801, 3249, 14, 5270, 63, 1838, 8, 57, 627, 2833, 14, 793, 8, 3577, 555, 14925, 395, 3114, 29, 17, 430, 199, 12290, 275, 2833, 14, 2834, 14, 9942, 26232, 13946, 8, 10546, 63, 1866, 29, 16, 14, 17, 680, 19333, 8, 6336, 9, 199, 199, 3, 1379, 1402, 199, 374, 63, 4525, 275, 2833, 14, 1452, 8, 3249, 14, 1273, 63, 988, 8, 3577, 555, 14925, 12, 413, 395, 2833, 14, 1273, 63, 988, 8, 57, 12, 413, 430, 199, 3, 12707, 12862, 199, 13374, 275, 2833, 14, 5270, 63, 3670, 8, 3249, 14, 2931, 8, 374, 63, 4525, 12, 2833, 14, 1609, 708, 430, 199, 199, 3, 2633, 199, 7588, 63, 13161, 275, 4114, 199, 2912, 63, 890, 275, 2948, 199, 199, 1045, 2833, 14, 4434, 342, 465, 4043, 26, 272, 327, 11578, 9134, 2860, 272, 4043, 14, 1065, 8, 3249, 14, 2966, 63, 3669, 63, 6498, 1012, 272, 327, 22859, 8643, 272, 367, 9463, 315, 1425, 8, 7588, 63, 13161, 304, 267, 12402, 63, 6336, 275, 378, 267, 3141, 63, 2912, 275, 1109, 8, 32164, 14, 2834, 14, 1507, 63, 8589, 1182, 3522, 63, 890, 9, 398, 367, 284, 315, 1425, 8, 2923, 63, 2912, 304, 288, 3522, 63, 7977, 12, 3522, 63, 588, 275, 21945, 631, 14, 2834, 14, 2184, 63, 2912, 8, 2912, 63, 890, 9, 288, 286, 12, 485, 275, 4043, 14, 1065, 779, 6336, 12, 10736, 467, 4733, 63, 807, 3126, 355, 1323, 26, 3522, 63, 7977, 12, 1488, 26, 3522, 63, 588, 1552, 288, 12402, 63, 6336, 847, 286, 1182, 3141, 63, 2912, 1467, 199, 1361, 360, 29322, 6536, 1543, 966, 68, 7, 450, 334, 7367, 435, 413, 395, 489, 283, 6336, 28414, 5041, 14010, 25, 70, 5285, 908, 8, 8595, 63, 6336, 430, 199, 199, 1361, 480, 25519, 9158, 531, 199, 199, 3, 1379, 314, 1402, 1808, 511, 5951, 199, 1361, 480, 1945, 7933, 26, 3872, 12862, 14, 2579, 8, 1730, 29, 5480, 12, 4733, 63, 807, 3126, 272, 1323, 26, 21945, 631, 14, 396, 14, 4782, 12, 1488, 26, 21945, 631, 14, 396, 14, 3512, 12466, 199, 199, 3, 2372, 1373, 436, 12610, 199, 82, 275, 2196, 14, 8393, 8, 16, 12, 21945, 631, 14, 396, 14, 1507, 63, 8589, 446, 413, 9, 199, 1361, 480, 4314, 26, 3872, 4043, 14, 1065, 8, 3249, 14, 16383, 8, 32164, 14, 396, 14, 3512, 59, 82, 26, 82, 435, 413, 467, 413, 1724, 199, 1361, 480, 24261, 26, 3872, 4043, 14, 1065, 8, 272, 2833, 14, 16383, 8, 3577, 555, 14925, 12, 413, 395, 4733, 63, 807, 3126, 56, 26, 21945, 631, 14, 396, 14, 4782, 59, 82, 26, 82, 435, 413, 9420, 430, 199, 199, 6003, 14, 20413, 8, 272, 21945, 631, 14, 396, 14, 4782, 59, 82, 26, 82, 435, 413, 1055, 5217, 8, 1651, 12, 7294, 395, 272, 14920, 534, 39, 264, 588, 297, 272, 14046, 534, 16615, 358, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Kongsea/tensorflow
tensorflow/examples/tutorials/layers/cnn_mnist.py
43
5711
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Convolutional Neural Network Estimator for MNIST, built with tf.layers.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf tf.logging.set_verbosity(tf.logging.INFO) def cnn_model_fn(features, labels, mode): """Model function for CNN.""" # Input Layer # Reshape X to 4-D tensor: [batch_size, width, height, channels] # MNIST images are 28x28 pixels, and have one color channel input_layer = tf.reshape(features["x"], [-1, 28, 28, 1]) # Convolutional Layer #1 # Computes 32 features using a 5x5 filter with ReLU activation. # Padding is added to preserve width and height. # Input Tensor Shape: [batch_size, 28, 28, 1] # Output Tensor Shape: [batch_size, 28, 28, 32] conv1 = tf.layers.conv2d( inputs=input_layer, filters=32, kernel_size=[5, 5], padding="same", activation=tf.nn.relu) # Pooling Layer #1 # First max pooling layer with a 2x2 filter and stride of 2 # Input Tensor Shape: [batch_size, 28, 28, 32] # Output Tensor Shape: [batch_size, 14, 14, 32] pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], strides=2) # Convolutional Layer #2 # Computes 64 features using a 5x5 filter. # Padding is added to preserve width and height. # Input Tensor Shape: [batch_size, 14, 14, 32] # Output Tensor Shape: [batch_size, 14, 14, 64] conv2 = tf.layers.conv2d( inputs=pool1, filters=64, kernel_size=[5, 5], padding="same", activation=tf.nn.relu) # Pooling Layer #2 # Second max pooling layer with a 2x2 filter and stride of 2 # Input Tensor Shape: [batch_size, 14, 14, 64] # Output Tensor Shape: [batch_size, 7, 7, 64] pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=[2, 2], strides=2) # Flatten tensor into a batch of vectors # Input Tensor Shape: [batch_size, 7, 7, 64] # Output Tensor Shape: [batch_size, 7 * 7 * 64] pool2_flat = tf.reshape(pool2, [-1, 7 * 7 * 64]) # Dense Layer # Densely connected layer with 1024 neurons # Input Tensor Shape: [batch_size, 7 * 7 * 64] # Output Tensor Shape: [batch_size, 1024] dense = tf.layers.dense(inputs=pool2_flat, units=1024, activation=tf.nn.relu) # Add dropout operation; 0.6 probability that element will be kept dropout = tf.layers.dropout( inputs=dense, rate=0.4, training=mode == tf.estimator.ModeKeys.TRAIN) # Logits layer # Input Tensor Shape: [batch_size, 1024] # Output Tensor Shape: [batch_size, 10] logits = tf.layers.dense(inputs=dropout, units=10) predictions = { # Generate predictions (for PREDICT and EVAL mode) "classes": tf.argmax(input=logits, axis=1), # Add `softmax_tensor` to the graph. It is used for PREDICT and by the # `logging_hook`. "probabilities": tf.nn.softmax(logits, name="softmax_tensor") } if mode == tf.estimator.ModeKeys.PREDICT: return tf.estimator.EstimatorSpec(mode=mode, predictions=predictions) # Calculate Loss (for both TRAIN and EVAL modes) loss = tf.losses.sparse_softmax_cross_entropy(labels=labels, logits=logits) # Configure the Training Op (for TRAIN mode) if mode == tf.estimator.ModeKeys.TRAIN: optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001) train_op = optimizer.minimize( loss=loss, global_step=tf.train.get_global_step()) return tf.estimator.EstimatorSpec(mode=mode, loss=loss, train_op=train_op) # Add evaluation metrics (for EVAL mode) eval_metric_ops = { "accuracy": tf.metrics.accuracy( labels=labels, predictions=predictions["classes"])} return tf.estimator.EstimatorSpec( mode=mode, loss=loss, eval_metric_ops=eval_metric_ops) def main(unused_argv): # Load training and eval data mnist = tf.contrib.learn.datasets.load_dataset("mnist") train_data = mnist.train.images # Returns np.array train_labels = np.asarray(mnist.train.labels, dtype=np.int32) eval_data = mnist.test.images # Returns np.array eval_labels = np.asarray(mnist.test.labels, dtype=np.int32) # Create the Estimator mnist_classifier = tf.estimator.Estimator( model_fn=cnn_model_fn, model_dir="/tmp/mnist_convnet_model") # Set up logging for predictions # Log the values in the "Softmax" tensor with label "probabilities" tensors_to_log = {"probabilities": "softmax_tensor"} logging_hook = tf.train.LoggingTensorHook( tensors=tensors_to_log, every_n_iter=50) # Train the model train_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": train_data}, y=train_labels, batch_size=100, num_epochs=None, shuffle=True) mnist_classifier.train( input_fn=train_input_fn, steps=20000, hooks=[logging_hook]) # Evaluate the model and print results eval_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": eval_data}, y=eval_labels, num_epochs=1, shuffle=False) eval_results = mnist_classifier.evaluate(input_fn=eval_input_fn) print(eval_results) if __name__ == "__main__": tf.app.run()
apache-2.0
[ 3, 221, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 624, 27394, 279, 5612, 4889, 7220, 28992, 367, 603, 25392, 12, 6137, 543, 2833, 14, 4359, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 3249, 14, 4806, 14, 409, 63, 9833, 8, 3249, 14, 4806, 14, 4531, 9, 421, 199, 318, 286, 4411, 63, 1238, 63, 2324, 8, 3179, 12, 3628, 12, 818, 304, 523, 408, 1685, 805, 367, 445, 7178, 1041, 523, 327, 6924, 11915, 523, 327, 3591, 15221, 1323, 370, 841, 13, 36, 2345, 26, 359, 2912, 63, 890, 12, 3462, 12, 4569, 12, 9245, 61, 523, 327, 603, 25392, 5935, 787, 7294, 88, 1651, 11094, 12, 436, 1172, 1373, 3164, 3623, 523, 1324, 63, 1897, 275, 2833, 14, 5217, 8, 3179, 905, 88, 2255, 5243, 17, 12, 7294, 12, 7294, 12, 413, 566, 819, 327, 19140, 3347, 279, 11915, 327, 17, 523, 327, 28040, 4337, 4534, 1808, 282, 959, 88, 21, 2457, 543, 799, 20237, 10361, 14, 523, 327, 510, 4095, 365, 3483, 370, 11211, 3462, 436, 4569, 14, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 7294, 12, 7294, 12, 413, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 7294, 12, 7294, 12, 4337, 61, 523, 8260, 17, 275, 2833, 14, 4359, 14, 5598, 18, 68, 8, 489, 4153, 29, 1210, 63, 1897, 12, 489, 4766, 29, 708, 12, 489, 5114, 63, 890, 1524, 21, 12, 959, 467, 489, 6273, 628, 7191, 401, 489, 10361, 29, 3249, 14, 4411, 14, 12833, 9, 819, 327, 15553, 316, 11915, 327, 17, 523, 327, 7758, 1390, 20699, 4045, 543, 282, 499, 88, 18, 2457, 436, 7345, 402, 499, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 7294, 12, 7294, 12, 4337, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 4337, 61, 523, 4203, 17, 275, 2833, 14, 4359, 14, 988, 63, 28624, 18, 68, 8, 3711, 29, 5598, 17, 12, 4203, 63, 890, 1524, 18, 12, 499, 467, 11883, 29, 18, 9, 819, 327, 19140, 3347, 279, 11915, 327, 18, 523, 327, 28040, 5049, 4534, 1808, 282, 959, 88, 21, 2457, 14, 523, 327, 510, 4095, 365, 3483, 370, 11211, 3462, 436, 4569, 14, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 4337, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 5049, 61, 523, 8260, 18, 275, 2833, 14, 4359, 14, 5598, 18, 68, 8, 489, 4153, 29, 2293, 17, 12, 489, 4766, 29, 772, 12, 489, 5114, 63, 890, 1524, 21, 12, 959, 467, 489, 6273, 628, 7191, 401, 489, 10361, 29, 3249, 14, 4411, 14, 12833, 9, 819, 327, 15553, 316, 11915, 327, 18, 523, 327, 16707, 1390, 20699, 4045, 543, 282, 499, 88, 18, 2457, 436, 7345, 402, 499, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 5049, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 12, 1520, 12, 5049, 61, 523, 4203, 18, 275, 2833, 14, 4359, 14, 988, 63, 28624, 18, 68, 8, 3711, 29, 5598, 18, 12, 4203, 63, 890, 1524, 18, 12, 499, 467, 11883, 29, 18, 9, 819, 327, 19005, 724, 2345, 1901, 282, 3522, 402, 11102, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 12, 1520, 12, 5049, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 627, 1520, 627, 5049, 61, 523, 4203, 18, 63, 7088, 275, 2833, 14, 5217, 8, 2293, 18, 12, 5243, 17, 12, 1520, 627, 1520, 627, 5049, 566, 819, 327, 20847, 11915, 523, 327, 20847, 590, 8539, 4045, 543, 6619, 1279, 32073, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 627, 1520, 627, 5049, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 6619, 61, 523, 9363, 275, 2833, 14, 4359, 14, 7253, 8, 3711, 29, 2293, 18, 63, 7088, 12, 6204, 29, 7727, 12, 10361, 29, 3249, 14, 4411, 14, 12833, 9, 819, 327, 2654, 19795, 3439, 27, 378, 14, 22, 12224, 626, 1819, 911, 506, 16204, 523, 19795, 275, 2833, 14, 4359, 14, 17953, 8, 489, 4153, 29, 7253, 12, 6634, 29, 16, 14, 20, 12, 6093, 29, 632, 508, 2833, 14, 8627, 14, 26870, 14, 18473, 9, 819, 327, 5297, 1405, 4045, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 6619, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1616, 61, 523, 11051, 275, 2833, 14, 4359, 14, 7253, 8, 3711, 29, 17953, 12, 6204, 29, 709, 9, 819, 7914, 275, 469, 489, 327, 7958, 7914, 334, 509, 510, 7387, 6196, 436, 662, 3204, 818, 9, 489, 298, 2888, 582, 2833, 14, 16383, 8, 1210, 29, 10492, 12, 3114, 29, 17, 395, 489, 327, 2654, 658, 16395, 63, 3128, 64, 370, 314, 3343, 14, 2779, 365, 1202, 367, 510, 7387, 6196, 436, 701, 314, 489, 327, 658, 4806, 63, 3664, 2313, 489, 298, 27583, 582, 2833, 14, 4411, 14, 16395, 8, 10492, 12, 536 ]
[ 221, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 624, 27394, 279, 5612, 4889, 7220, 28992, 367, 603, 25392, 12, 6137, 543, 2833, 14, 4359, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 3249, 14, 4806, 14, 409, 63, 9833, 8, 3249, 14, 4806, 14, 4531, 9, 421, 199, 318, 286, 4411, 63, 1238, 63, 2324, 8, 3179, 12, 3628, 12, 818, 304, 523, 408, 1685, 805, 367, 445, 7178, 1041, 523, 327, 6924, 11915, 523, 327, 3591, 15221, 1323, 370, 841, 13, 36, 2345, 26, 359, 2912, 63, 890, 12, 3462, 12, 4569, 12, 9245, 61, 523, 327, 603, 25392, 5935, 787, 7294, 88, 1651, 11094, 12, 436, 1172, 1373, 3164, 3623, 523, 1324, 63, 1897, 275, 2833, 14, 5217, 8, 3179, 905, 88, 2255, 5243, 17, 12, 7294, 12, 7294, 12, 413, 566, 819, 327, 19140, 3347, 279, 11915, 327, 17, 523, 327, 28040, 4337, 4534, 1808, 282, 959, 88, 21, 2457, 543, 799, 20237, 10361, 14, 523, 327, 510, 4095, 365, 3483, 370, 11211, 3462, 436, 4569, 14, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 7294, 12, 7294, 12, 413, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 7294, 12, 7294, 12, 4337, 61, 523, 8260, 17, 275, 2833, 14, 4359, 14, 5598, 18, 68, 8, 489, 4153, 29, 1210, 63, 1897, 12, 489, 4766, 29, 708, 12, 489, 5114, 63, 890, 1524, 21, 12, 959, 467, 489, 6273, 628, 7191, 401, 489, 10361, 29, 3249, 14, 4411, 14, 12833, 9, 819, 327, 15553, 316, 11915, 327, 17, 523, 327, 7758, 1390, 20699, 4045, 543, 282, 499, 88, 18, 2457, 436, 7345, 402, 499, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 7294, 12, 7294, 12, 4337, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 4337, 61, 523, 4203, 17, 275, 2833, 14, 4359, 14, 988, 63, 28624, 18, 68, 8, 3711, 29, 5598, 17, 12, 4203, 63, 890, 1524, 18, 12, 499, 467, 11883, 29, 18, 9, 819, 327, 19140, 3347, 279, 11915, 327, 18, 523, 327, 28040, 5049, 4534, 1808, 282, 959, 88, 21, 2457, 14, 523, 327, 510, 4095, 365, 3483, 370, 11211, 3462, 436, 4569, 14, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 4337, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 5049, 61, 523, 8260, 18, 275, 2833, 14, 4359, 14, 5598, 18, 68, 8, 489, 4153, 29, 2293, 17, 12, 489, 4766, 29, 772, 12, 489, 5114, 63, 890, 1524, 21, 12, 959, 467, 489, 6273, 628, 7191, 401, 489, 10361, 29, 3249, 14, 4411, 14, 12833, 9, 819, 327, 15553, 316, 11915, 327, 18, 523, 327, 16707, 1390, 20699, 4045, 543, 282, 499, 88, 18, 2457, 436, 7345, 402, 499, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 4329, 12, 4329, 12, 5049, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 12, 1520, 12, 5049, 61, 523, 4203, 18, 275, 2833, 14, 4359, 14, 988, 63, 28624, 18, 68, 8, 3711, 29, 5598, 18, 12, 4203, 63, 890, 1524, 18, 12, 499, 467, 11883, 29, 18, 9, 819, 327, 19005, 724, 2345, 1901, 282, 3522, 402, 11102, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 12, 1520, 12, 5049, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 627, 1520, 627, 5049, 61, 523, 4203, 18, 63, 7088, 275, 2833, 14, 5217, 8, 2293, 18, 12, 5243, 17, 12, 1520, 627, 1520, 627, 5049, 566, 819, 327, 20847, 11915, 523, 327, 20847, 590, 8539, 4045, 543, 6619, 1279, 32073, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1520, 627, 1520, 627, 5049, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 6619, 61, 523, 9363, 275, 2833, 14, 4359, 14, 7253, 8, 3711, 29, 2293, 18, 63, 7088, 12, 6204, 29, 7727, 12, 10361, 29, 3249, 14, 4411, 14, 12833, 9, 819, 327, 2654, 19795, 3439, 27, 378, 14, 22, 12224, 626, 1819, 911, 506, 16204, 523, 19795, 275, 2833, 14, 4359, 14, 17953, 8, 489, 4153, 29, 7253, 12, 6634, 29, 16, 14, 20, 12, 6093, 29, 632, 508, 2833, 14, 8627, 14, 26870, 14, 18473, 9, 819, 327, 5297, 1405, 4045, 523, 327, 6924, 5878, 16528, 26, 359, 2912, 63, 890, 12, 6619, 61, 523, 327, 7242, 5878, 16528, 26, 359, 2912, 63, 890, 12, 1616, 61, 523, 11051, 275, 2833, 14, 4359, 14, 7253, 8, 3711, 29, 17953, 12, 6204, 29, 709, 9, 819, 7914, 275, 469, 489, 327, 7958, 7914, 334, 509, 510, 7387, 6196, 436, 662, 3204, 818, 9, 489, 298, 2888, 582, 2833, 14, 16383, 8, 1210, 29, 10492, 12, 3114, 29, 17, 395, 489, 327, 2654, 658, 16395, 63, 3128, 64, 370, 314, 3343, 14, 2779, 365, 1202, 367, 510, 7387, 6196, 436, 701, 314, 489, 327, 658, 4806, 63, 3664, 2313, 489, 298, 27583, 582, 2833, 14, 4411, 14, 16395, 8, 10492, 12, 536, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
JDongian/LangGrind
src/parse_raw.py
1
1957
"""Parse human data into JSON""" import string def parse_file(filename="../data/RAW.txt"): """Parse human readable file into JSON.""" entries = [] with open(filename) as f_in: next_line = f_in.readline() data = {} state = "section" while next_line: if state == "section": line = next_line.split(" ") if line[0] == "Chapter": data = {'section': {'chapter': int(line[1]), 'part': line[4].strip()}} state = "term" elif state == "term": if not next_line.strip(): state = "section" next_line = f_in.readline() continue entry = data.copy() term, definition = next_line.split(";") #print("'{}'".format(next_line)) entry['term'] = term.strip() entry['definitions'] = [_.strip() for\ _ in definition.split(",")] entry['class'] = [] # Determine the lexical class of the word. if "(be)" in "".join(entry['definitions']): entry['class'].append("adjective") for _ in entry['definitions']: initial = _.split(" ")[0] end = _[-1] if initial in ["a", "an"]: entry['class'].append("noun") if initial in ["to"]: entry['class'].append("verb") if end in ".!?": entry['class'].append("phrase") # Proper nouns elif initial[0] in string.ascii_uppercase: entry['class'].append("noun") entries.append(entry) next_line = f_in.readline() return entries
gpl-3.0
[ 624, 4003, 11779, 666, 1901, 4840, 624, 199, 646, 1059, 199, 199, 318, 2198, 63, 493, 8, 1501, 628, 5093, 576, 15, 4307, 14, 2424, 2349, 272, 408, 4003, 11779, 12701, 570, 1901, 4840, 1041, 339, 4811, 275, 942, 272, 543, 1551, 8, 1501, 9, 465, 289, 63, 262, 26, 267, 2163, 63, 604, 275, 289, 63, 262, 14, 6407, 342, 267, 666, 275, 1052, 267, 1174, 275, 298, 2792, 2, 267, 1830, 2163, 63, 604, 26, 288, 340, 1174, 508, 298, 2792, 582, 355, 1004, 275, 2163, 63, 604, 14, 1294, 480, 6099, 355, 340, 1004, 59, 16, 61, 508, 298, 30791, 582, 490, 666, 275, 791, 2792, 356, 791, 11316, 356, 1109, 8, 604, 59, 17, 2522, 3147, 283, 2064, 356, 1004, 59, 20, 1055, 1913, 342, 4863, 490, 1174, 275, 298, 5125, 2, 288, 916, 1174, 508, 298, 5125, 582, 355, 340, 440, 2163, 63, 604, 14, 1913, 837, 490, 1174, 275, 298, 2792, 2, 490, 2163, 63, 604, 275, 289, 63, 262, 14, 6407, 342, 490, 1980, 355, 2397, 275, 666, 14, 1574, 342, 355, 6707, 12, 5492, 275, 2163, 63, 604, 14, 1294, 480, 15027, 355, 327, 1361, 15587, 2440, 7, 1674, 908, 8, 2184, 63, 604, 430, 2234, 2397, 459, 5125, 418, 275, 6707, 14, 1913, 342, 355, 2397, 459, 15388, 418, 275, 359, 3754, 1913, 342, 367, 60, 3147, 485, 315, 5492, 14, 1294, 11854, 11323, 355, 2397, 459, 533, 418, 275, 942, 2234, 327, 14703, 314, 7103, 2652, 1021, 402, 314, 4349, 14, 355, 340, 7340, 1235, 2924, 315, 10587, 904, 8, 2373, 459, 15388, 9090, 490, 2397, 459, 533, 2278, 740, 480, 12551, 6850, 531, 355, 367, 485, 315, 2397, 459, 15388, 2565, 490, 2536, 275, 485, 14, 1294, 480, 298, 2788, 16, 61, 490, 1284, 275, 485, 1988, 17, 61, 490, 340, 2536, 315, 2097, 65, 401, 298, 290, 6229, 717, 2397, 459, 533, 2278, 740, 480, 889, 324, 531, 490, 340, 2536, 315, 2097, 475, 6229, 717, 2397, 459, 533, 2278, 740, 480, 17050, 531, 490, 340, 1284, 315, 3680, 1, 31, 582, 717, 2397, 459, 533, 2278, 740, 480, 10906, 531, 490, 327, 2165, 529, 949, 324, 83, 490, 916, 2536, 59, 16, 61, 315, 1059, 14, 4371, 63, 26831, 26, 717, 2397, 459, 533, 2278, 740, 480, 889, 324, 531, 355, 4811, 14, 740, 8, 2373, 9, 288, 2163, 63, 604, 275, 289, 63, 262, 14, 6407, 342, 272, 372, 4811, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4003, 11779, 666, 1901, 4840, 624, 199, 646, 1059, 199, 199, 318, 2198, 63, 493, 8, 1501, 628, 5093, 576, 15, 4307, 14, 2424, 2349, 272, 408, 4003, 11779, 12701, 570, 1901, 4840, 1041, 339, 4811, 275, 942, 272, 543, 1551, 8, 1501, 9, 465, 289, 63, 262, 26, 267, 2163, 63, 604, 275, 289, 63, 262, 14, 6407, 342, 267, 666, 275, 1052, 267, 1174, 275, 298, 2792, 2, 267, 1830, 2163, 63, 604, 26, 288, 340, 1174, 508, 298, 2792, 582, 355, 1004, 275, 2163, 63, 604, 14, 1294, 480, 6099, 355, 340, 1004, 59, 16, 61, 508, 298, 30791, 582, 490, 666, 275, 791, 2792, 356, 791, 11316, 356, 1109, 8, 604, 59, 17, 2522, 3147, 283, 2064, 356, 1004, 59, 20, 1055, 1913, 342, 4863, 490, 1174, 275, 298, 5125, 2, 288, 916, 1174, 508, 298, 5125, 582, 355, 340, 440, 2163, 63, 604, 14, 1913, 837, 490, 1174, 275, 298, 2792, 2, 490, 2163, 63, 604, 275, 289, 63, 262, 14, 6407, 342, 490, 1980, 355, 2397, 275, 666, 14, 1574, 342, 355, 6707, 12, 5492, 275, 2163, 63, 604, 14, 1294, 480, 15027, 355, 327, 1361, 15587, 2440, 7, 1674, 908, 8, 2184, 63, 604, 430, 2234, 2397, 459, 5125, 418, 275, 6707, 14, 1913, 342, 355, 2397, 459, 15388, 418, 275, 359, 3754, 1913, 342, 367, 60, 3147, 485, 315, 5492, 14, 1294, 11854, 11323, 355, 2397, 459, 533, 418, 275, 942, 2234, 327, 14703, 314, 7103, 2652, 1021, 402, 314, 4349, 14, 355, 340, 7340, 1235, 2924, 315, 10587, 904, 8, 2373, 459, 15388, 9090, 490, 2397, 459, 533, 2278, 740, 480, 12551, 6850, 531, 355, 367, 485, 315, 2397, 459, 15388, 2565, 490, 2536, 275, 485, 14, 1294, 480, 298, 2788, 16, 61, 490, 1284, 275, 485, 1988, 17, 61, 490, 340, 2536, 315, 2097, 65, 401, 298, 290, 6229, 717, 2397, 459, 533, 2278, 740, 480, 889, 324, 531, 490, 340, 2536, 315, 2097, 475, 6229, 717, 2397, 459, 533, 2278, 740, 480, 17050, 531, 490, 340, 1284, 315, 3680, 1, 31, 582, 717, 2397, 459, 533, 2278, 740, 480, 10906, 531, 490, 327, 2165, 529, 949, 324, 83, 490, 916, 2536, 59, 16, 61, 315, 1059, 14, 4371, 63, 26831, 26, 717, 2397, 459, 533, 2278, 740, 480, 889, 324, 531, 355, 4811, 14, 740, 8, 2373, 9, 288, 2163, 63, 604, 275, 289, 63, 262, 14, 6407, 342, 272, 372, 4811, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aidan-/ansible-modules-extras
network/exoscale/exo_dns_record.py
31
12145
#!/usr/bin/python # -*- coding: utf-8 -*- # # (c) 2016, René Moser <mail@renemoser.net> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: exo_dns_record short_description: Manages DNS records on Exoscale DNS. description: - Create, update and delete records. version_added: "2.2" author: "René Moser (@resmo)" options: name: description: - Name of the record. required: false default: "" domain: description: - Domain the record is related to. required: true record_type: description: - Type of the record. required: false default: A choices: ['A', 'ALIAS', 'CNAME', 'MX', 'SPF', 'URL', 'TXT', 'NS', 'SRV', 'NAPTR', 'PTR', 'AAAA', 'SSHFP', 'HINFO', 'POOL'] aliases: ['rtype', 'type'] content: description: - Content of the record. - Required if C(state=present) or C(name="") required: false default: null aliases: ['value', 'address'] ttl: description: - TTL of the record in seconds. required: false default: 3600 prio: description: - Priority of the record. required: false default: null aliases: ['priority'] multiple: description: - Whether there are more than one records with similar C(name). - Only allowed with C(record_type=A). - C(content) will not be updated as it is used as key to find the record. required: false default: null aliases: ['priority'] state: description: - State of the record. required: false default: 'present' choices: [ 'present', 'absent' ] api_key: description: - API key of the Exoscale DNS API. required: false default: null api_secret: description: - Secret key of the Exoscale DNS API. required: false default: null api_timeout: description: - HTTP timeout to Exoscale DNS API. required: false default: 10 api_region: description: - Name of the ini section in the C(cloustack.ini) file. required: false default: cloudstack validate_certs: description: - Validate SSL certs of the Exoscale DNS API. required: false default: true requirements: - "python >= 2.6" notes: - As Exoscale DNS uses the same API key and secret for all services, we reuse the config used for Exscale Compute based on CloudStack. The config is read from several locations, in the following order. The C(CLOUDSTACK_KEY), C(CLOUDSTACK_SECRET) environment variables. A C(CLOUDSTACK_CONFIG) environment variable pointing to an C(.ini) file, A C(cloudstack.ini) file in the current working directory. A C(.cloudstack.ini) file in the users home directory. Optionally multiple credentials and endpoints can be specified using ini sections in C(cloudstack.ini). Use the argument C(api_region) to select the section name, default section is C(cloudstack). - This module does not support multiple A records and will complain properly if you try. - More information Exoscale DNS can be found on https://community.exoscale.ch/documentation/dns/. - This module supports check mode and diff. ''' EXAMPLES = ''' # Create or update an A record. - local_action: module: exo_dns_record name: web-vm-1 domain: example.com content: 1.2.3.4 # Update an existing A record with a new IP. - local_action: module: exo_dns_record name: web-vm-1 domain: example.com content: 1.2.3.5 # Create another A record with same name. - local_action: module: exo_dns_record name: web-vm-1 domain: example.com content: 1.2.3.6 multiple: yes # Create or update a CNAME record. - local_action: module: exo_dns_record name: www domain: example.com record_type: CNAME content: web-vm-1 # Create or update a MX record. - local_action: module: exo_dns_record domain: example.com record_type: MX content: mx1.example.com prio: 10 # delete a MX record. - local_action: module: exo_dns_record domain: example.com record_type: MX content: mx1.example.com state: absent # Remove a record. - local_action: module: exo_dns_record name: www domain: example.com state: absent ''' RETURN = ''' --- exo_dns_record: description: API record results returned: success type: dictionary contains: content: description: value of the record returned: success type: string sample: 1.2.3.4 created_at: description: When the record was created returned: success type: string sample: "2016-08-12T15:24:23.989Z" domain: description: Name of the domain returned: success type: string sample: example.com domain_id: description: ID of the domain returned: success type: int sample: 254324 id: description: ID of the record returned: success type: int sample: 254324 name: description: name of the record returned: success type: string sample: www parent_id: description: ID of the parent returned: success type: int sample: null prio: description: Priority of the record returned: success type: int sample: 10 record_type: description: Priority of the record returned: success type: string sample: A system_record: description: Whether the record is a system record or not returned: success type: bool sample: false ttl: description: Time to live of the record returned: success type: int sample: 3600 updated_at: description: When the record was updated returned: success type: string sample: "2016-08-12T15:24:23.989Z" ''' # import exoscale common from ansible.module_utils.exoscale import * class ExoDnsRecord(ExoDns): def __init__(self, module): super(ExoDnsRecord, self).__init__(module) self.content = self.module.params.get('content') if self.content: self.content = self.content.lower() self.domain = self.module.params.get('domain').lower() self.name = self.module.params.get('name').lower() if self.name == self.domain: self.name = "" self.multiple = self.module.params.get('multiple') self.record_type = self.module.params.get('record_type') if self.multiple and self.record_type != 'A': self.module.fail_json("Multiple is only usable with record_type A") def _create_record(self, record): self.result['changed'] = True data = { 'record': { 'name': self.name, 'record_type': self.record_type, 'content': self.content, 'ttl': self.module.params.get('ttl'), 'prio': self.module.params.get('prio'), } } self.result['diff']['after'] = data['record'] if not self.module.check_mode: record = self.api_query("/domains/%s/records" % self.domain, "POST", data) return record def _update_record(self, record): data = { 'record': { 'name': self.name, 'content': self.content, 'ttl': self.module.params.get('ttl'), 'prio': self.module.params.get('prio'), } } if self.has_changed(data['record'], record['record']): self.result['changed'] = True if not self.module.check_mode: record = self.api_query("/domains/%s/records/%s" % (self.domain, record['record']['id']), "PUT", data) return record def get_record(self): domain = self.module.params.get('domain') records = self.api_query("/domains/%s/records" % domain, "GET") record = None for r in records: found_record = None if r['record']['record_type'] == self.record_type: r_name = r['record']['name'].lower() r_content = r['record']['content'].lower() # there are multiple A records but we found an exact match if self.multiple and self.name == r_name and self.content == r_content: record = r break # We do not expect to found more then one record with that content if not self.multiple and not self.name and self.content == r_content: found_record = r # We do not expect to found more then one record with that name elif not self.multiple and self.name and self.name == r_name: found_record = r if record and found_record: self.module.fail_json(msg="More than one record with your params. Use multiple=yes for more than one A record.") if found_record: record = found_record return record def present_record(self): record = self.get_record() if not record: record = self._create_record(record); else: record = self._update_record(record); return record def absent_record(self): record = self.get_record() if record: self.result['diff']['before'] = record self.result['changed'] = True if not self.module.check_mode: self.api_query("/domains/%s/records/%s" % (self.domain, record['record']['id']), "DELETE") return record def get_result(self, resource): if resource: self.result['exo_dns_record'] = resource['record'] self.result['exo_dns_record']['domain'] = self.domain return self.result def main(): argument_spec = exo_dns_argument_spec() argument_spec.update(dict( name=dict(default=""), record_type=dict(choices=['A', 'ALIAS', 'CNAME', 'MX', 'SPF', 'URL', 'TXT', 'NS', 'SRV', 'NAPTR', 'PTR', 'AAAA', 'SSHFP', 'HINFO', 'POOL'], aliases=['rtype', 'type'], default='A'), content=dict(aliases=['value', 'address']), multiple=(dict(type='bool', default=False)), ttl=dict(type='int', default=3600), prio=dict(type='int', aliases=['priority']), domain=dict(required=True), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=exo_dns_required_together(), required_if=[ ['state', 'present', ['content']], ['name', '', ['content']], ], required_one_of=[ ['content', 'name'], ], supports_check_mode=True, ) exo_dns_record = ExoDnsRecord(module) if module.params.get('state') == "present": resource = exo_dns_record.present_record() else: resource = exo_dns_record.absent_record() result = exo_dns_record.get_result(resource) module.exit_json(**result) # import module snippets from ansible.module_utils.basic import * if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 7800, 12, 10055, 5741, 3930, 332, 665, 1198, 32, 264, 685, 573, 332, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 444, 79, 63, 5797, 63, 3059, 199, 3612, 63, 1802, 26, 21612, 10237, 5767, 641, 1316, 79, 3467, 10237, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 436, 3145, 5767, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 298, 5349, 5741, 3930, 332, 8593, 470, 573, 2924, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 3087, 523, 2881, 26, 272, 1369, 26, 489, 446, 14061, 314, 2777, 365, 4048, 370, 14, 272, 1415, 26, 2549, 523, 2777, 63, 466, 26, 272, 1369, 26, 489, 446, 2434, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 437, 272, 3415, 26, 788, 33, 297, 283, 12644, 297, 283, 35, 2339, 297, 283, 17401, 297, 283, 5763, 38, 297, 283, 2632, 297, 283, 17715, 297, 283, 2709, 297, 283, 31546, 297, 283, 46, 1282, 1766, 297, 283, 14528, 297, 283, 6151, 297, 283, 13716, 17095, 297, 283, 40, 4531, 297, 283, 19693, 418, 272, 5481, 26, 788, 4500, 297, 283, 466, 418, 523, 1564, 26, 272, 1369, 26, 489, 446, 6646, 402, 314, 2777, 14, 489, 446, 11105, 340, 445, 8, 929, 29, 1881, 9, 503, 445, 8, 354, 18413, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 585, 297, 283, 1562, 418, 523, 14856, 26, 272, 1369, 26, 489, 446, 30822, 402, 314, 2777, 315, 4696, 14, 272, 1415, 26, 3055, 272, 849, 26, 15751, 523, 20449, 26, 272, 1369, 26, 489, 446, 8538, 3822, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 6693, 418, 523, 3663, 26, 272, 1369, 26, 489, 446, 7480, 2337, 787, 1655, 2419, 1373, 5767, 543, 8545, 445, 8, 354, 680, 489, 446, 5972, 4370, 543, 445, 8, 3059, 63, 466, 29, 33, 680, 489, 446, 445, 8, 1317, 9, 911, 440, 506, 4588, 465, 652, 365, 1202, 465, 790, 370, 2342, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 6693, 418, 523, 1174, 26, 272, 1369, 26, 489, 446, 8511, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 1881, 7, 272, 3415, 26, 359, 283, 1881, 297, 283, 5575, 7, 1622, 523, 2986, 63, 498, 26, 272, 1369, 26, 489, 446, 3261, 790, 402, 314, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 4731, 26, 272, 1369, 26, 489, 446, 23580, 790, 402, 314, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 2593, 26, 272, 1369, 26, 489, 446, 3101, 2653, 370, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 1616, 523, 2986, 63, 4551, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 20364, 3420, 315, 314, 445, 8, 1251, 833, 564, 14, 2730, 9, 570, 14, 272, 1415, 26, 3055, 272, 849, 26, 8002, 2340, 523, 4107, 63, 8356, 26, 272, 1369, 26, 489, 446, 12134, 7799, 25949, 402, 314, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2549, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 199, 5983, 26, 523, 446, 3709, 1316, 79, 3467, 10237, 4440, 314, 2011, 3261, 790, 436, 7565, 367, 1006, 8500, 12, 781, 12598, 314, 1101, 1202, 367, 1316, 3467, 8354, 4079, 641, 8142, 4851, 14, 272, 710, 1101, 365, 1586, 687, 9978, 9918, 12, 315, 314, 2569, 1865, 14, 272, 710, 445, 8, 29495, 17014, 63, 3078, 395, 445, 8, 29495, 17014, 63, 12961, 9, 3734, 2860, 14, 272, 437, 445, 8, 29495, 17014, 63, 5569, 9, 3734, 1750, 20686, 370, 376, 445, 13417, 2730, 9, 570, 12, 272, 437, 445, 8, 4091, 2340, 14, 2730, 9, 570, 315, 314, 1453, 6449, 2082, 14, 272, 437, 445, 13417, 4091, 2340, 14, 2730, 9, 570, 315, 314, 4390, 5629, 2082, 14, 272, 22383, 3663, 6235, 436, 16173, 883, 506, 2013, 1808, 20364, 10189, 315, 445, 8, 4091, 2340, 14, 2730, 680, 272, 3645, 314, 1423, 445, 8, 1246, 63, 4551, 9, 370, 3504, 314, 3420, 536, 12, 849, 3420, 365, 445, 8, 4091, 2340, 680, 523, 446, 961, 859, 1630, 440, 2291, 3663, 437, 5767, 436, 911, 24105, 7684, 340, 1265, 862, 14, 523, 446, 16917, 2556, 1316, 79, 3467, 10237, 883, 506, 1911, 641, 4178, 921, 9387, 14, 476, 79, 3467, 14, 335, 15, 9970, 15, 5797, 8083, 523, 446, 961, 859, 5171, 1104, 818, 436, 3915, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 503, 1678, 376, 437, 2777, 14, 199, 13, 2257, 63, 1287, 26, 272, 859, 26, 444, 79, 63, 5797, 63, 3059, 272, 536, 26, 3330, 13, 2611, 13, 17, 272, 2881, 26, 2893, 14, 957, 272, 1564, 26, 413, 14, 18, 14, 19, 14, 20, 199, 199, 3, 6162, 376 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 7800, 12, 10055, 5741, 3930, 332, 665, 1198, 32, 264, 685, 573, 332, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 444, 79, 63, 5797, 63, 3059, 199, 3612, 63, 1802, 26, 21612, 10237, 5767, 641, 1316, 79, 3467, 10237, 14, 199, 1802, 26, 272, 446, 2790, 12, 1678, 436, 3145, 5767, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 298, 5349, 5741, 3930, 332, 8593, 470, 573, 2924, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 3087, 523, 2881, 26, 272, 1369, 26, 489, 446, 14061, 314, 2777, 365, 4048, 370, 14, 272, 1415, 26, 2549, 523, 2777, 63, 466, 26, 272, 1369, 26, 489, 446, 2434, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 437, 272, 3415, 26, 788, 33, 297, 283, 12644, 297, 283, 35, 2339, 297, 283, 17401, 297, 283, 5763, 38, 297, 283, 2632, 297, 283, 17715, 297, 283, 2709, 297, 283, 31546, 297, 283, 46, 1282, 1766, 297, 283, 14528, 297, 283, 6151, 297, 283, 13716, 17095, 297, 283, 40, 4531, 297, 283, 19693, 418, 272, 5481, 26, 788, 4500, 297, 283, 466, 418, 523, 1564, 26, 272, 1369, 26, 489, 446, 6646, 402, 314, 2777, 14, 489, 446, 11105, 340, 445, 8, 929, 29, 1881, 9, 503, 445, 8, 354, 18413, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 585, 297, 283, 1562, 418, 523, 14856, 26, 272, 1369, 26, 489, 446, 30822, 402, 314, 2777, 315, 4696, 14, 272, 1415, 26, 3055, 272, 849, 26, 15751, 523, 20449, 26, 272, 1369, 26, 489, 446, 8538, 3822, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 6693, 418, 523, 3663, 26, 272, 1369, 26, 489, 446, 7480, 2337, 787, 1655, 2419, 1373, 5767, 543, 8545, 445, 8, 354, 680, 489, 446, 5972, 4370, 543, 445, 8, 3059, 63, 466, 29, 33, 680, 489, 446, 445, 8, 1317, 9, 911, 440, 506, 4588, 465, 652, 365, 1202, 465, 790, 370, 2342, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 788, 6693, 418, 523, 1174, 26, 272, 1369, 26, 489, 446, 8511, 402, 314, 2777, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 1881, 7, 272, 3415, 26, 359, 283, 1881, 297, 283, 5575, 7, 1622, 523, 2986, 63, 498, 26, 272, 1369, 26, 489, 446, 3261, 790, 402, 314, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 4731, 26, 272, 1369, 26, 489, 446, 23580, 790, 402, 314, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 2593, 26, 272, 1369, 26, 489, 446, 3101, 2653, 370, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 1616, 523, 2986, 63, 4551, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 20364, 3420, 315, 314, 445, 8, 1251, 833, 564, 14, 2730, 9, 570, 14, 272, 1415, 26, 3055, 272, 849, 26, 8002, 2340, 523, 4107, 63, 8356, 26, 272, 1369, 26, 489, 446, 12134, 7799, 25949, 402, 314, 1316, 79, 3467, 10237, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2549, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 199, 5983, 26, 523, 446, 3709, 1316, 79, 3467, 10237, 4440, 314, 2011, 3261, 790, 436, 7565, 367, 1006, 8500, 12, 781, 12598, 314, 1101, 1202, 367, 1316, 3467, 8354, 4079, 641, 8142, 4851, 14, 272, 710, 1101, 365, 1586, 687, 9978, 9918, 12, 315, 314, 2569, 1865, 14, 272, 710, 445, 8, 29495, 17014, 63, 3078, 395, 445, 8, 29495, 17014, 63, 12961, 9, 3734, 2860, 14, 272, 437, 445, 8, 29495, 17014, 63, 5569, 9, 3734, 1750, 20686, 370, 376, 445, 13417, 2730, 9, 570, 12, 272, 437, 445, 8, 4091, 2340, 14, 2730, 9, 570, 315, 314, 1453, 6449, 2082, 14, 272, 437, 445, 13417, 4091, 2340, 14, 2730, 9, 570, 315, 314, 4390, 5629, 2082, 14, 272, 22383, 3663, 6235, 436, 16173, 883, 506, 2013, 1808, 20364, 10189, 315, 445, 8, 4091, 2340, 14, 2730, 680, 272, 3645, 314, 1423, 445, 8, 1246, 63, 4551, 9, 370, 3504, 314, 3420, 536, 12, 849, 3420, 365, 445, 8, 4091, 2340, 680, 523, 446, 961, 859, 1630, 440, 2291, 3663, 437, 5767, 436, 911, 24105, 7684, 340, 1265, 862, 14, 523, 446, 16917, 2556, 1316, 79, 3467, 10237, 883, 506, 1911, 641, 4178, 921, 9387, 14, 476, 79, 3467, 14, 335, 15, 9970, 15, 5797, 8083, 523, 446, 961, 859, 5171, 1104, 818, 436, 3915, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 503, 1678, 376, 437, 2777, 14, 199, 13, 2257, 63, 1287, 26, 272, 859, 26, 444, 79, 63, 5797, 63, 3059, 272, 536, 26, 3330, 13, 2611, 13, 17, 272, 2881, 26, 2893, 14, 957, 272, 1564, 26, 413, 14, 18, 14, 19, 14, 20, 199, 199, 3, 6162, 376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 1, 1, 1 ]
slevenhagen/odoo-npg
openerp/addons/base/ir/ir_default.py
342
1883
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv class ir_default(osv.osv): _name = 'ir.default' _columns = { 'field_tbl': fields.char('Object'), 'field_name': fields.char('Object Field'), 'value': fields.char('Default Value'), 'uid': fields.many2one('res.users', 'Users'), 'page': fields.char('View'), 'ref_table': fields.char('Table Ref.'), 'ref_id': fields.integer('ID Ref.',size=64), 'company_id': fields.many2one('res.company','Company') } def _get_company_id(self, cr, uid, context=None): res = self.pool.get('res.users').read(cr, uid, [uid], ['company_id'], context=context) if res and res[0]['company_id']: return res[0]['company_id'][0] return False _defaults = { 'company_id': _get_company_id, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 8190, 63, 885, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 723, 14, 885, 7, 272, 485, 3406, 275, 469, 267, 283, 698, 63, 14806, 356, 1504, 14, 1560, 360, 1692, 659, 267, 283, 698, 63, 354, 356, 1504, 14, 1560, 360, 1692, 5024, 659, 267, 283, 585, 356, 1504, 14, 1560, 360, 2698, 1594, 659, 267, 283, 1535, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 12117, 659, 267, 283, 1606, 356, 1504, 14, 1560, 360, 2768, 659, 267, 283, 1121, 63, 1224, 356, 1504, 14, 1560, 360, 3186, 15397, 8038, 267, 283, 1121, 63, 344, 356, 1504, 14, 4115, 360, 998, 15397, 3130, 890, 29, 772, 395, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 1673, 16063, 358, 272, 789, 339, 347, 485, 362, 63, 4627, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 522, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 739, 8, 1556, 12, 1747, 12, 359, 1535, 467, 788, 4627, 63, 344, 995, 1067, 29, 1100, 9, 267, 340, 522, 436, 522, 59, 16, 2733, 4627, 63, 344, 2565, 288, 372, 522, 59, 16, 2733, 4627, 63, 344, 3488, 16, 61, 267, 372, 756, 339, 485, 4322, 275, 469, 267, 283, 4627, 63, 344, 356, 485, 362, 63, 4627, 63, 344, 12, 272, 789, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 8190, 63, 885, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 723, 14, 885, 7, 272, 485, 3406, 275, 469, 267, 283, 698, 63, 14806, 356, 1504, 14, 1560, 360, 1692, 659, 267, 283, 698, 63, 354, 356, 1504, 14, 1560, 360, 1692, 5024, 659, 267, 283, 585, 356, 1504, 14, 1560, 360, 2698, 1594, 659, 267, 283, 1535, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 12117, 659, 267, 283, 1606, 356, 1504, 14, 1560, 360, 2768, 659, 267, 283, 1121, 63, 1224, 356, 1504, 14, 1560, 360, 3186, 15397, 8038, 267, 283, 1121, 63, 344, 356, 1504, 14, 4115, 360, 998, 15397, 3130, 890, 29, 772, 395, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 1673, 16063, 358, 272, 789, 339, 347, 485, 362, 63, 4627, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 522, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 739, 8, 1556, 12, 1747, 12, 359, 1535, 467, 788, 4627, 63, 344, 995, 1067, 29, 1100, 9, 267, 340, 522, 436, 522, 59, 16, 2733, 4627, 63, 344, 2565, 288, 372, 522, 59, 16, 2733, 4627, 63, 344, 3488, 16, 61, 267, 372, 756, 339, 485, 4322, 275, 469, 267, 283, 4627, 63, 344, 356, 485, 362, 63, 4627, 63, 344, 12, 272, 789, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jaidevd/scikit-learn
sklearn/externals/joblib/testing.py
23
3042
""" Helper for testing. """ import sys import warnings import os.path import re import subprocess import threading from sklearn.externals.joblib._compat import PY3_OR_LATER def warnings_to_stdout(): """ Redirect all warnings to stdout. """ showwarning_orig = warnings.showwarning def showwarning(msg, cat, fname, lno, file=None, line=0): showwarning_orig(msg, cat, os.path.basename(fname), line, sys.stdout) warnings.showwarning = showwarning #warnings.simplefilter('always') try: from nose.tools import assert_raises_regex except ImportError: # For Python 2.7 try: from nose.tools import assert_raises_regexp as assert_raises_regex except ImportError: # for Python 2.6 def assert_raises_regex(expected_exception, expected_regexp, callable_obj=None, *args, **kwargs): """Helper function to check for message patterns in exceptions""" not_raised = False try: callable_obj(*args, **kwargs) not_raised = True except Exception as e: error_message = str(e) if not re.compile(expected_regexp).search(error_message): raise AssertionError("Error message should match pattern " "%r. %r does not." % (expected_regexp, error_message)) if not_raised: raise AssertionError("Should have raised %r" % expected_exception(expected_regexp)) def check_subprocess_call(cmd, timeout=1, stdout_regex=None, stderr_regex=None): """Runs a command in a subprocess with timeout in seconds. Also checks returncode is zero, stdout if stdout_regex is set, and stderr if stderr_regex is set. """ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) def kill_process(): proc.kill() timer = threading.Timer(timeout, kill_process) try: timer.start() stdout, stderr = proc.communicate() if PY3_OR_LATER: stdout, stderr = stdout.decode(), stderr.decode() if proc.returncode != 0: message = ( 'Non-zero return code: {0}.\nStdout:\n{1}\n' 'Stderr:\n{2}').format( proc.returncode, stdout, stderr) raise ValueError(message) if (stdout_regex is not None and not re.search(stdout_regex, stdout)): raise ValueError( "Unexpected stdout: {0!r} does not match:\n{1!r}".format( stdout_regex, stdout)) if (stderr_regex is not None and not re.search(stderr_regex, stderr)): raise ValueError( "Unexpected stderr: {0!r} does not match:\n{1!r}".format( stderr_regex, stderr)) finally: timer.cancel()
bsd-3-clause
[ 624, 199, 4433, 367, 5343, 14, 199, 624, 199, 199, 646, 984, 199, 646, 3598, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 3873, 199, 646, 5796, 199, 199, 504, 6357, 14, 24688, 14, 2423, 773, 423, 5819, 492, 7843, 19, 63, 726, 63, 44, 10447, 421, 199, 318, 3598, 63, 475, 63, 2703, 837, 272, 408, 18532, 1006, 3598, 370, 3839, 14, 272, 408, 272, 930, 25268, 63, 2981, 275, 3598, 14, 29109, 339, 347, 930, 25268, 8, 1328, 12, 6230, 12, 6748, 12, 634, 889, 12, 570, 29, 403, 12, 1004, 29, 16, 304, 267, 930, 25268, 63, 2981, 8, 1328, 12, 6230, 12, 747, 14, 515, 14, 4846, 8, 5252, 395, 1004, 12, 984, 14, 2703, 9, 339, 3598, 14, 29109, 275, 930, 25268, 272, 327, 5451, 14, 18815, 360, 9223, 358, 421, 199, 893, 26, 272, 687, 11354, 14, 2537, 492, 702, 63, 3536, 63, 3821, 199, 2590, 3545, 26, 272, 327, 2104, 2018, 499, 14, 23, 272, 862, 26, 267, 687, 11354, 14, 2537, 492, 702, 63, 3536, 63, 11191, 465, 702, 63, 3536, 63, 3821, 272, 871, 3545, 26, 267, 327, 367, 2018, 499, 14, 22, 267, 347, 702, 63, 3536, 63, 3821, 8, 2062, 63, 1971, 12, 1420, 63, 11191, 12, 1816, 4550, 63, 1113, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 288, 408, 4433, 805, 370, 1104, 367, 1245, 7970, 315, 4967, 624, 953, 440, 63, 21597, 275, 756, 288, 862, 26, 355, 4550, 63, 1113, 2031, 589, 12, 1011, 958, 9, 355, 440, 63, 21597, 275, 715, 288, 871, 2186, 465, 325, 26, 355, 1125, 63, 1188, 275, 620, 8, 69, 9, 355, 340, 440, 295, 14, 2014, 8, 2062, 63, 11191, 680, 1733, 8, 705, 63, 1188, 304, 490, 746, 9070, 480, 547, 1245, 1077, 1336, 3851, 298, 1460, 2071, 82, 14, 450, 82, 1630, 440, 2122, 450, 1460, 334, 2062, 63, 11191, 12, 1125, 63, 1188, 430, 288, 340, 440, 63, 21597, 26, 355, 746, 9070, 480, 11408, 1172, 4915, 450, 82, 2, 450, 3660, 1420, 63, 1971, 8, 2062, 63, 11191, 430, 421, 199, 318, 1104, 63, 5781, 63, 1250, 8, 1760, 12, 2653, 29, 17, 12, 3839, 63, 3821, 29, 403, 12, 2079, 4635, 63, 3821, 29, 403, 304, 272, 408, 16291, 282, 1414, 315, 282, 3873, 543, 2653, 315, 4696, 14, 339, 6121, 5920, 17630, 365, 4697, 12, 3839, 340, 3839, 63, 3821, 365, 663, 12, 436, 272, 4635, 340, 4635, 63, 3821, 365, 663, 14, 272, 408, 272, 6499, 275, 3873, 14, 7942, 8, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 1169, 4635, 29, 5781, 14, 6089, 9, 339, 347, 14561, 63, 1412, 837, 267, 6499, 14, 8997, 342, 339, 9715, 275, 5796, 14, 7929, 8, 2593, 12, 14561, 63, 1412, 9, 272, 862, 26, 267, 9715, 14, 928, 342, 267, 3839, 12, 4635, 275, 6499, 14, 10664, 342, 398, 340, 7843, 19, 63, 726, 63, 44, 10447, 26, 288, 3839, 12, 4635, 275, 3839, 14, 2708, 1062, 4635, 14, 2708, 342, 267, 340, 6499, 14, 9913, 1137, 378, 26, 288, 1245, 275, 334, 355, 283, 6932, 13, 4262, 372, 1233, 26, 469, 16, 93, 3134, 78, 26080, 3427, 78, 91, 17, 4988, 78, 7, 355, 283, 933, 2303, 3427, 78, 91, 18, 93, 1959, 908, 8, 490, 6499, 14, 9913, 12, 3839, 12, 4635, 9, 288, 746, 1722, 8, 1188, 9, 398, 340, 334, 2703, 63, 3821, 365, 440, 488, 436, 355, 440, 295, 14, 1733, 8, 2703, 63, 3821, 12, 3839, 2298, 288, 746, 1722, 8, 355, 298, 8708, 3839, 26, 469, 16, 1, 82, 93, 1630, 440, 1336, 3427, 78, 91, 17, 1, 82, 5469, 908, 8, 490, 3839, 63, 3821, 12, 3839, 430, 267, 340, 334, 3083, 63, 3821, 365, 440, 488, 436, 355, 440, 295, 14, 1733, 8, 3083, 63, 3821, 12, 4635, 2298, 288, 746, 1722, 8, 355, 298, 8708, 4635, 26, 469, 16, 1, 82, 93, 1630, 440, 1336, 3427, 78, 91, 17, 1, 82, 5469, 908, 8, 490, 4635, 63, 3821, 12, 4635, 430, 339, 3753, 26, 267, 9715, 14, 6406, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 4433, 367, 5343, 14, 199, 624, 199, 199, 646, 984, 199, 646, 3598, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 3873, 199, 646, 5796, 199, 199, 504, 6357, 14, 24688, 14, 2423, 773, 423, 5819, 492, 7843, 19, 63, 726, 63, 44, 10447, 421, 199, 318, 3598, 63, 475, 63, 2703, 837, 272, 408, 18532, 1006, 3598, 370, 3839, 14, 272, 408, 272, 930, 25268, 63, 2981, 275, 3598, 14, 29109, 339, 347, 930, 25268, 8, 1328, 12, 6230, 12, 6748, 12, 634, 889, 12, 570, 29, 403, 12, 1004, 29, 16, 304, 267, 930, 25268, 63, 2981, 8, 1328, 12, 6230, 12, 747, 14, 515, 14, 4846, 8, 5252, 395, 1004, 12, 984, 14, 2703, 9, 339, 3598, 14, 29109, 275, 930, 25268, 272, 327, 5451, 14, 18815, 360, 9223, 358, 421, 199, 893, 26, 272, 687, 11354, 14, 2537, 492, 702, 63, 3536, 63, 3821, 199, 2590, 3545, 26, 272, 327, 2104, 2018, 499, 14, 23, 272, 862, 26, 267, 687, 11354, 14, 2537, 492, 702, 63, 3536, 63, 11191, 465, 702, 63, 3536, 63, 3821, 272, 871, 3545, 26, 267, 327, 367, 2018, 499, 14, 22, 267, 347, 702, 63, 3536, 63, 3821, 8, 2062, 63, 1971, 12, 1420, 63, 11191, 12, 1816, 4550, 63, 1113, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 288, 408, 4433, 805, 370, 1104, 367, 1245, 7970, 315, 4967, 624, 953, 440, 63, 21597, 275, 756, 288, 862, 26, 355, 4550, 63, 1113, 2031, 589, 12, 1011, 958, 9, 355, 440, 63, 21597, 275, 715, 288, 871, 2186, 465, 325, 26, 355, 1125, 63, 1188, 275, 620, 8, 69, 9, 355, 340, 440, 295, 14, 2014, 8, 2062, 63, 11191, 680, 1733, 8, 705, 63, 1188, 304, 490, 746, 9070, 480, 547, 1245, 1077, 1336, 3851, 298, 1460, 2071, 82, 14, 450, 82, 1630, 440, 2122, 450, 1460, 334, 2062, 63, 11191, 12, 1125, 63, 1188, 430, 288, 340, 440, 63, 21597, 26, 355, 746, 9070, 480, 11408, 1172, 4915, 450, 82, 2, 450, 3660, 1420, 63, 1971, 8, 2062, 63, 11191, 430, 421, 199, 318, 1104, 63, 5781, 63, 1250, 8, 1760, 12, 2653, 29, 17, 12, 3839, 63, 3821, 29, 403, 12, 2079, 4635, 63, 3821, 29, 403, 304, 272, 408, 16291, 282, 1414, 315, 282, 3873, 543, 2653, 315, 4696, 14, 339, 6121, 5920, 17630, 365, 4697, 12, 3839, 340, 3839, 63, 3821, 365, 663, 12, 436, 272, 4635, 340, 4635, 63, 3821, 365, 663, 14, 272, 408, 272, 6499, 275, 3873, 14, 7942, 8, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 1169, 4635, 29, 5781, 14, 6089, 9, 339, 347, 14561, 63, 1412, 837, 267, 6499, 14, 8997, 342, 339, 9715, 275, 5796, 14, 7929, 8, 2593, 12, 14561, 63, 1412, 9, 272, 862, 26, 267, 9715, 14, 928, 342, 267, 3839, 12, 4635, 275, 6499, 14, 10664, 342, 398, 340, 7843, 19, 63, 726, 63, 44, 10447, 26, 288, 3839, 12, 4635, 275, 3839, 14, 2708, 1062, 4635, 14, 2708, 342, 267, 340, 6499, 14, 9913, 1137, 378, 26, 288, 1245, 275, 334, 355, 283, 6932, 13, 4262, 372, 1233, 26, 469, 16, 93, 3134, 78, 26080, 3427, 78, 91, 17, 4988, 78, 7, 355, 283, 933, 2303, 3427, 78, 91, 18, 93, 1959, 908, 8, 490, 6499, 14, 9913, 12, 3839, 12, 4635, 9, 288, 746, 1722, 8, 1188, 9, 398, 340, 334, 2703, 63, 3821, 365, 440, 488, 436, 355, 440, 295, 14, 1733, 8, 2703, 63, 3821, 12, 3839, 2298, 288, 746, 1722, 8, 355, 298, 8708, 3839, 26, 469, 16, 1, 82, 93, 1630, 440, 1336, 3427, 78, 91, 17, 1, 82, 5469, 908, 8, 490, 3839, 63, 3821, 12, 3839, 430, 267, 340, 334, 3083, 63, 3821, 365, 440, 488, 436, 355, 440, 295, 14, 1733, 8, 3083, 63, 3821, 12, 4635, 2298, 288, 746, 1722, 8, 355, 298, 8708, 4635, 26, 469, 16, 1, 82, 93, 1630, 440, 1336, 3427, 78, 91, 17, 1, 82, 5469, 908, 8, 490, 4635, 63, 3821, 12, 4635, 430, 339, 3753, 26, 267, 9715, 14, 6406, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jxzhxch/androguard
androguard/core/bytecodes/arm.py
48
2306
# Radare ! from r2 import r_bin from r2 import r_asm from r2 import r_anal from r2 import r_core from miasm.arch.arm_arch import arm_mn from miasm.core.bin_stream import bin_stream from miasm.core import asmbloc class ARM2 : def __init__(self) : b = r_bin.RBin () b.load("./apks/exploits/617efb2d51ad5c4aed50b76119ad880c6adcd4d2e386b3170930193525b0563d", None) baddr= b.get_baddr() print '-> Sections' for i in b.get_sections (): print 'offset=0x%08x va=0x%08x size=%05i %s' % (i.offset, baddr+i.rva, i.size, i.name) core = r_core.RCore() core.config.set_i("io.va", 1) core.config.set_i("anal.split", 1) core.file_open("./apks/exploits/617efb2d51ad5c4aed50b76119ad880c6adcd4d2e386b3170930193525b0563d", 0, 0) core.bin_load( None ) core.anal_all() for fcn in core.anal.get_fcns() : print type(fcn), fcn.type, "%x" % fcn.addr, fcn.ninstr, fcn.name # if (fcn.type == FcnType_FCN or fcn.type == FcnType_SYM): for s in core.bin.get_entries() : print s, type(s), s.rva, "%x" % s.offset #a = r_asm.RAsm() for s in core.bin.get_symbols() : print s, s.name, s.rva, s.offset, s.size if s.name == "rootshell" : #print core.disassemble_bytes( 0x8000 + s.offset, s.size ) #core.assembler.mdisassemble( 0x8000 + s.offset, s.size ) z = core.op_anal( 0x8000 + s.offset ) print z.mnemonic raise("oo") print core.bin.bins, core.bin.user d = core.bin.read_at( 0x8000 + s.offset, x, s.size ) print d raise("ooo") j = 0 while j < s.size : v = core.disassemble( 0x8000 + s.offset + j ) v1 = core.op_str( 0x8000 + s.offset + j ) print v1 # print 0x8000 + s.offset + j, j, v.inst_len, v.buf_asm j += v.inst_len #for i in core.asm_bwdisassemble(s.rva, 4, s.size/4) : # print "la", i # print a.mdisassemble( 20, 0x90 ) #"main", "main" ) #s.name )
apache-2.0
[ 3, 820, 350, 1530, 8546, 199, 199, 504, 519, 18, 492, 519, 63, 1393, 199, 504, 519, 18, 492, 519, 63, 11374, 199, 504, 519, 18, 492, 519, 63, 290, 279, 199, 504, 519, 18, 492, 519, 63, 1018, 199, 199, 504, 333, 2241, 77, 14, 1047, 14, 5362, 63, 1047, 492, 30701, 63, 10344, 199, 504, 333, 2241, 77, 14, 1018, 14, 1393, 63, 1745, 492, 221, 2517, 63, 1745, 199, 504, 333, 2241, 77, 14, 1018, 492, 465, 887, 2102, 421, 199, 533, 27155, 18, 520, 272, 347, 636, 826, 721, 277, 9, 520, 267, 330, 275, 519, 63, 1393, 14, 50, 13394, 6248, 267, 330, 14, 912, 28615, 439, 6080, 15, 16971, 1405, 15, 28630, 2829, 66, 18, 68, 2869, 350, 21, 67, 20, 65, 379, 1400, 66, 2114, 7119, 350, 30321, 67, 22, 350, 2866, 20, 68, 18, 69, 8040, 66, 21974, 1643, 8507, 32258, 821, 66, 16, 18199, 68, 401, 488, 9, 267, 330, 2697, 29, 330, 14, 362, 63, 66, 2697, 342, 267, 870, 2475, 30, 3240, 2452, 7, 267, 367, 284, 315, 330, 14, 362, 63, 7786, 23390, 288, 870, 283, 2743, 29, 16, 88, 5, 2036, 88, 25819, 29, 16, 88, 5, 2036, 88, 1568, 2458, 1717, 73, 450, 83, 7, 450, 334, 73, 14, 2743, 12, 330, 2697, 11, 73, 14, 82, 3042, 12, 284, 14, 890, 12, 284, 14, 354, 9, 398, 6170, 275, 519, 63, 1018, 14, 50, 5402, 342, 267, 6170, 14, 888, 14, 409, 63, 73, 480, 2308, 14, 3042, 401, 413, 9, 267, 6170, 14, 888, 14, 409, 63, 73, 480, 290, 279, 14, 1294, 401, 413, 9, 398, 6170, 14, 493, 63, 1490, 28615, 439, 6080, 15, 16971, 1405, 15, 28630, 2829, 66, 18, 68, 2869, 350, 21, 67, 20, 65, 379, 1400, 66, 2114, 7119, 350, 30321, 67, 22, 350, 2866, 20, 68, 18, 69, 8040, 66, 21974, 1643, 8507, 32258, 821, 66, 16, 18199, 68, 401, 378, 12, 378, 9, 267, 6170, 14, 1393, 63, 912, 8, 488, 776, 398, 6170, 14, 290, 279, 63, 452, 342, 398, 367, 289, 6413, 315, 6170, 14, 290, 279, 14, 362, 63, 3003, 561, 342, 520, 288, 870, 730, 8, 26554, 395, 289, 6413, 14, 466, 12, 2071, 88, 2, 450, 289, 6413, 14, 2697, 12, 289, 6413, 14, 78, 21309, 12, 289, 6413, 14, 354, 288, 327, 8540, 340, 334, 26554, 14, 466, 508, 481, 6413, 804, 63, 4161, 46, 503, 289, 6413, 14, 466, 508, 481, 6413, 804, 63, 30637, 304, 398, 367, 308, 315, 6170, 14, 1393, 14, 362, 63, 3189, 342, 520, 288, 870, 308, 12, 730, 8, 83, 395, 308, 14, 82, 3042, 12, 2071, 88, 2, 450, 308, 14, 2743, 7318, 327, 65, 275, 519, 63, 11374, 14, 50, 2822, 77, 342, 267, 367, 308, 315, 6170, 14, 1393, 14, 362, 63, 7450, 342, 520, 288, 870, 308, 12, 308, 14, 354, 12, 308, 14, 82, 3042, 12, 308, 14, 2743, 12, 308, 14, 890, 288, 340, 308, 14, 354, 508, 298, 1231, 5641, 2, 520, 355, 327, 1361, 6170, 14, 2297, 21263, 63, 2394, 8, 378, 88, 15214, 435, 308, 14, 2743, 12, 308, 14, 890, 776, 355, 355, 327, 1018, 14, 21263, 82, 14, 77, 2297, 21263, 8, 378, 88, 15214, 435, 308, 14, 2743, 12, 308, 14, 890, 776, 355, 1315, 275, 6170, 14, 411, 63, 290, 279, 8, 378, 88, 15214, 435, 308, 14, 2743, 776, 355, 870, 1315, 14, 22599, 16082, 2234, 746, 480, 1534, 531, 14977, 870, 6170, 14, 1393, 14, 11329, 12, 6170, 14, 1393, 14, 751, 355, 366, 275, 6170, 14, 1393, 14, 739, 63, 292, 8, 378, 88, 15214, 435, 308, 14, 2743, 12, 671, 12, 308, 14, 890, 776, 355, 870, 366, 355, 746, 480, 1534, 79, 531, 355, 1335, 275, 378, 355, 1830, 1335, 665, 308, 14, 890, 520, 490, 373, 275, 6170, 14, 2297, 21263, 8, 378, 88, 15214, 435, 308, 14, 2743, 435, 1335, 776, 490, 373, 17, 275, 6170, 14, 411, 63, 495, 8, 378, 88, 15214, 435, 308, 14, 2743, 435, 1335, 776, 4951, 870, 373, 17, 355, 327, 259, 870, 378, 88, 15214, 435, 308, 14, 2743, 435, 1335, 12, 1335, 12, 373, 14, 3615, 63, 552, 12, 373, 14, 1436, 63, 11374, 490, 1335, 847, 373, 14, 3615, 63, 552, 2234, 327, 509, 284, 315, 6170, 14, 11374, 63, 12415, 2297, 21263, 8, 83, 14, 82, 3042, 12, 841, 12, 308, 14, 890, 15, 20, 9, 520, 355, 327, 259, 870, 298, 416, 401, 284, 267, 327, 259, 870, 282, 14, 77, 2297, 21263, 8, 3388, 12, 378, 88, 2710, 776, 20383, 973, 401, 298, 973, 2, 776, 327, 83, 14, 354, 776, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 820, 350, 1530, 8546, 199, 199, 504, 519, 18, 492, 519, 63, 1393, 199, 504, 519, 18, 492, 519, 63, 11374, 199, 504, 519, 18, 492, 519, 63, 290, 279, 199, 504, 519, 18, 492, 519, 63, 1018, 199, 199, 504, 333, 2241, 77, 14, 1047, 14, 5362, 63, 1047, 492, 30701, 63, 10344, 199, 504, 333, 2241, 77, 14, 1018, 14, 1393, 63, 1745, 492, 221, 2517, 63, 1745, 199, 504, 333, 2241, 77, 14, 1018, 492, 465, 887, 2102, 421, 199, 533, 27155, 18, 520, 272, 347, 636, 826, 721, 277, 9, 520, 267, 330, 275, 519, 63, 1393, 14, 50, 13394, 6248, 267, 330, 14, 912, 28615, 439, 6080, 15, 16971, 1405, 15, 28630, 2829, 66, 18, 68, 2869, 350, 21, 67, 20, 65, 379, 1400, 66, 2114, 7119, 350, 30321, 67, 22, 350, 2866, 20, 68, 18, 69, 8040, 66, 21974, 1643, 8507, 32258, 821, 66, 16, 18199, 68, 401, 488, 9, 267, 330, 2697, 29, 330, 14, 362, 63, 66, 2697, 342, 267, 870, 2475, 30, 3240, 2452, 7, 267, 367, 284, 315, 330, 14, 362, 63, 7786, 23390, 288, 870, 283, 2743, 29, 16, 88, 5, 2036, 88, 25819, 29, 16, 88, 5, 2036, 88, 1568, 2458, 1717, 73, 450, 83, 7, 450, 334, 73, 14, 2743, 12, 330, 2697, 11, 73, 14, 82, 3042, 12, 284, 14, 890, 12, 284, 14, 354, 9, 398, 6170, 275, 519, 63, 1018, 14, 50, 5402, 342, 267, 6170, 14, 888, 14, 409, 63, 73, 480, 2308, 14, 3042, 401, 413, 9, 267, 6170, 14, 888, 14, 409, 63, 73, 480, 290, 279, 14, 1294, 401, 413, 9, 398, 6170, 14, 493, 63, 1490, 28615, 439, 6080, 15, 16971, 1405, 15, 28630, 2829, 66, 18, 68, 2869, 350, 21, 67, 20, 65, 379, 1400, 66, 2114, 7119, 350, 30321, 67, 22, 350, 2866, 20, 68, 18, 69, 8040, 66, 21974, 1643, 8507, 32258, 821, 66, 16, 18199, 68, 401, 378, 12, 378, 9, 267, 6170, 14, 1393, 63, 912, 8, 488, 776, 398, 6170, 14, 290, 279, 63, 452, 342, 398, 367, 289, 6413, 315, 6170, 14, 290, 279, 14, 362, 63, 3003, 561, 342, 520, 288, 870, 730, 8, 26554, 395, 289, 6413, 14, 466, 12, 2071, 88, 2, 450, 289, 6413, 14, 2697, 12, 289, 6413, 14, 78, 21309, 12, 289, 6413, 14, 354, 288, 327, 8540, 340, 334, 26554, 14, 466, 508, 481, 6413, 804, 63, 4161, 46, 503, 289, 6413, 14, 466, 508, 481, 6413, 804, 63, 30637, 304, 398, 367, 308, 315, 6170, 14, 1393, 14, 362, 63, 3189, 342, 520, 288, 870, 308, 12, 730, 8, 83, 395, 308, 14, 82, 3042, 12, 2071, 88, 2, 450, 308, 14, 2743, 7318, 327, 65, 275, 519, 63, 11374, 14, 50, 2822, 77, 342, 267, 367, 308, 315, 6170, 14, 1393, 14, 362, 63, 7450, 342, 520, 288, 870, 308, 12, 308, 14, 354, 12, 308, 14, 82, 3042, 12, 308, 14, 2743, 12, 308, 14, 890, 288, 340, 308, 14, 354, 508, 298, 1231, 5641, 2, 520, 355, 327, 1361, 6170, 14, 2297, 21263, 63, 2394, 8, 378, 88, 15214, 435, 308, 14, 2743, 12, 308, 14, 890, 776, 355, 355, 327, 1018, 14, 21263, 82, 14, 77, 2297, 21263, 8, 378, 88, 15214, 435, 308, 14, 2743, 12, 308, 14, 890, 776, 355, 1315, 275, 6170, 14, 411, 63, 290, 279, 8, 378, 88, 15214, 435, 308, 14, 2743, 776, 355, 870, 1315, 14, 22599, 16082, 2234, 746, 480, 1534, 531, 14977, 870, 6170, 14, 1393, 14, 11329, 12, 6170, 14, 1393, 14, 751, 355, 366, 275, 6170, 14, 1393, 14, 739, 63, 292, 8, 378, 88, 15214, 435, 308, 14, 2743, 12, 671, 12, 308, 14, 890, 776, 355, 870, 366, 355, 746, 480, 1534, 79, 531, 355, 1335, 275, 378, 355, 1830, 1335, 665, 308, 14, 890, 520, 490, 373, 275, 6170, 14, 2297, 21263, 8, 378, 88, 15214, 435, 308, 14, 2743, 435, 1335, 776, 490, 373, 17, 275, 6170, 14, 411, 63, 495, 8, 378, 88, 15214, 435, 308, 14, 2743, 435, 1335, 776, 4951, 870, 373, 17, 355, 327, 259, 870, 378, 88, 15214, 435, 308, 14, 2743, 435, 1335, 12, 1335, 12, 373, 14, 3615, 63, 552, 12, 373, 14, 1436, 63, 11374, 490, 1335, 847, 373, 14, 3615, 63, 552, 2234, 327, 509, 284, 315, 6170, 14, 11374, 63, 12415, 2297, 21263, 8, 83, 14, 82, 3042, 12, 841, 12, 308, 14, 890, 15, 20, 9, 520, 355, 327, 259, 870, 298, 416, 401, 284, 267, 327, 259, 870, 282, 14, 77, 2297, 21263, 8, 3388, 12, 378, 88, 2710, 776, 20383, 973, 401, 298, 973, 2, 776, 327, 83, 14, 354, 776, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Compile an .idl file to Blink V8 bindings (.h and .cpp files). Design doc: http://www.chromium.org/developers/design-documents/idl-compiler """ import abc from optparse import OptionParser import os import cPickle as pickle import sys from code_generator_v8 import CodeGeneratorDictionaryImpl, CodeGeneratorV8, CodeGeneratorUnionType from idl_reader import IdlReader from utilities import create_component_info_provider, read_idl_files_list_from_file, write_file, idl_filename_to_component def parse_options(): parser = OptionParser() parser.add_option('--cache-directory', help='cache directory, defaults to output directory') parser.add_option('--generate-impl', action="store_true", default=False) parser.add_option('--output-directory') parser.add_option('--impl-output-directory') parser.add_option('--info-dir') parser.add_option('--write-file-only-if-changed', type='int') # FIXME: We should always explicitly specify --target-component and # remove the default behavior. parser.add_option('--target-component', help='target component to generate code, defaults to ' 'component of input idl file') # ensure output comes last, so command line easy to parse via regexes parser.disable_interspersed_args() options, args = parser.parse_args() if options.output_directory is None: parser.error('Must specify output directory using --output-directory.') options.write_file_only_if_changed = bool(options.write_file_only_if_changed) if len(args) != 1: parser.error('Must specify exactly 1 input file as argument, but %d given.' % len(args)) idl_filename = os.path.realpath(args[0]) return options, idl_filename def idl_filename_to_interface_name(idl_filename): basename = os.path.basename(idl_filename) interface_name, _ = os.path.splitext(basename) return interface_name class IdlCompiler(object): """Abstract Base Class for IDL compilers. In concrete classes: * self.code_generator must be set, implementing generate_code() (returning a list of output code), and * compile_file() must be implemented (handling output filenames). """ __metaclass__ = abc.ABCMeta def __init__(self, output_directory, cache_directory=None, code_generator=None, info_provider=None, only_if_changed=False, target_component=None): """ Args: output_directory: directory to put output files. cache_directory: directory which contains PLY caches. code_generator: code generator to be used. info_provider: component-specific information provider. only_if_changed: True when the compiler should only write output files when the contents are changed. target_component: component to be processed. """ self.cache_directory = cache_directory self.code_generator = code_generator self.info_provider = info_provider self.only_if_changed = only_if_changed self.output_directory = output_directory self.target_component = target_component self.reader = IdlReader(info_provider.interfaces_info, cache_directory) def compile_and_write(self, idl_filename): interface_name = idl_filename_to_interface_name(idl_filename) definitions = self.reader.read_idl_definitions(idl_filename) target_component = self.target_component or idl_filename_to_component(idl_filename) target_definitions = definitions[target_component] output_code_list = self.code_generator.generate_code( target_definitions, interface_name) for output_path, output_code in output_code_list: write_file(output_code, output_path, self.only_if_changed) @abc.abstractmethod def compile_file(self, idl_filename): pass class IdlCompilerV8(IdlCompiler): def __init__(self, *args, **kwargs): IdlCompiler.__init__(self, *args, **kwargs) self.code_generator = CodeGeneratorV8(self.info_provider, self.cache_directory, self.output_directory) def compile_file(self, idl_filename): self.compile_and_write(idl_filename) class IdlCompilerDictionaryImpl(IdlCompiler): def __init__(self, *args, **kwargs): IdlCompiler.__init__(self, *args, **kwargs) self.code_generator = CodeGeneratorDictionaryImpl( self.info_provider, self.cache_directory, self.output_directory) def compile_file(self, idl_filename): self.compile_and_write(idl_filename) def generate_bindings(options, input_filename): info_provider = create_component_info_provider( options.info_dir, options.target_component) idl_compiler = IdlCompilerV8( options.output_directory, cache_directory=options.cache_directory, info_provider=info_provider, only_if_changed=options.write_file_only_if_changed, target_component=options.target_component) idl_compiler.compile_file(input_filename) def generate_dictionary_impl(options, input_filename): info_provider = create_component_info_provider( options.info_dir, options.target_component) idl_compiler = IdlCompilerDictionaryImpl( options.impl_output_directory, cache_directory=options.cache_directory, info_provider=info_provider, only_if_changed=options.write_file_only_if_changed) idl_filenames = read_idl_files_list_from_file(input_filename, is_gyp_format=True) for idl_filename in idl_filenames: idl_compiler.compile_file(idl_filename) def generate_union_type_containers(options): info_provider = create_component_info_provider( options.info_dir, options.target_component) if not info_provider.interfaces_info: raise Exception('Interfaces info is required to generate ' 'union types containers') generator = CodeGeneratorUnionType( info_provider, options.cache_directory, options.output_directory, options.target_component) output_code_list = generator.generate_code() for output_path, output_code in output_code_list: write_file(output_code, output_path, options.write_file_only_if_changed) def main(): options, input_filename = parse_options() if options.generate_impl: # |input_filename| should be a file which contains a list of IDL # dictionary paths. generate_dictionary_impl(options, input_filename) generate_union_type_containers(options) else: # |input_filename| should be a path of an IDL file. generate_bindings(options, input_filename) if __name__ == '__main__': sys.exit(main())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 35, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 12626, 376, 1275, 13398, 570, 370, 699, 1073, 812, 24, 17792, 17048, 72, 436, 1275, 5910, 1584, 680, 199, 199, 20924, 1382, 26, 1455, 921, 1544, 14, 13211, 14, 1308, 15, 23826, 15, 14748, 13, 12233, 15, 13398, 13, 5772, 199, 624, 199, 199, 646, 13022, 199, 504, 8691, 492, 13491, 199, 646, 747, 199, 646, 17572, 465, 5927, 199, 646, 984, 199, 199, 504, 1233, 63, 4679, 63, 86, 24, 492, 5495, 7599, 11728, 4748, 12, 5495, 7599, 54, 24, 12, 5495, 7599, 15540, 804, 199, 504, 20365, 63, 5503, 492, 473, 5030, 5929, 199, 504, 15841, 492, 1218, 63, 3173, 63, 815, 63, 3780, 12, 1586, 63, 13398, 63, 1725, 63, 513, 63, 504, 63, 493, 12, 2218, 63, 493, 12, 20365, 63, 1501, 63, 475, 63, 3173, 421, 199, 318, 2198, 63, 1419, 837, 272, 1798, 275, 13491, 342, 272, 1798, 14, 525, 63, 1422, 4517, 1637, 13, 3619, 297, 1993, 1720, 534, 1637, 2082, 12, 4243, 370, 1072, 2082, 358, 272, 1798, 14, 525, 63, 1422, 4517, 4208, 13, 5472, 297, 1993, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 9, 272, 1798, 14, 525, 63, 1422, 4517, 1199, 13, 3619, 358, 272, 1798, 14, 525, 63, 1422, 4517, 5472, 13, 1199, 13, 3619, 358, 272, 1798, 14, 525, 63, 1422, 4517, 815, 13, 694, 358, 272, 1798, 14, 525, 63, 1422, 4517, 952, 13, 493, 13, 2118, 13, 692, 13, 2489, 297, 730, 534, 442, 358, 272, 327, 7600, 26, 2136, 1077, 3544, 7662, 4165, 1553, 1375, 13, 3173, 436, 272, 327, 2813, 314, 849, 5953, 14, 272, 1798, 14, 525, 63, 1422, 4517, 1375, 13, 3173, 297, 1993, 1720, 534, 1375, 3931, 370, 3550, 1233, 12, 4243, 370, 283, 1993, 283, 3173, 402, 1324, 20365, 570, 358, 272, 327, 4868, 1072, 12477, 2061, 12, 880, 1414, 1004, 8837, 370, 2198, 4799, 5163, 397, 272, 1798, 14, 5993, 63, 11005, 529, 939, 63, 589, 342, 339, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 1511, 14, 1199, 63, 3619, 365, 488, 26, 267, 1798, 14, 705, 360, 13757, 4165, 1072, 2082, 1808, 1553, 1199, 13, 3619, 2659, 272, 1511, 14, 952, 63, 493, 63, 2118, 63, 692, 63, 2489, 275, 2155, 8, 1419, 14, 952, 63, 493, 63, 2118, 63, 692, 63, 2489, 9, 272, 340, 822, 8, 589, 9, 1137, 413, 26, 267, 1798, 14, 705, 360, 13757, 4165, 8840, 413, 1324, 570, 465, 1423, 12, 1325, 450, 68, 1627, 3530, 450, 822, 8, 589, 430, 272, 20365, 63, 1501, 275, 747, 14, 515, 14, 11091, 8, 589, 59, 16, 566, 272, 372, 1511, 12, 20365, 63, 1501, 421, 199, 318, 20365, 63, 1501, 63, 475, 63, 3266, 63, 354, 8, 13398, 63, 1501, 304, 272, 9593, 275, 747, 14, 515, 14, 4846, 8, 13398, 63, 1501, 9, 272, 3217, 63, 354, 12, 485, 275, 747, 14, 515, 14, 7973, 8, 4846, 9, 272, 372, 3217, 63, 354, 421, 199, 533, 473, 5030, 9131, 8, 785, 304, 272, 408, 8458, 3523, 8089, 367, 14575, 29784, 14, 339, 1010, 13801, 3992, 26, 272, 627, 291, 14, 600, 63, 4679, 1471, 506, 663, 12, 18234, 3550, 63, 600, 342, 489, 334, 24112, 282, 769, 402, 1072, 1233, 395, 436, 272, 627, 6555, 63, 493, 342, 1471, 506, 6366, 334, 22273, 1072, 6203, 680, 272, 408, 272, 636, 6577, 363, 275, 13022, 14, 22254, 339, 347, 636, 826, 721, 277, 12, 1072, 63, 3619, 12, 2581, 63, 3619, 29, 403, 12, 326, 1233, 63, 4679, 29, 403, 12, 2256, 63, 3780, 29, 403, 12, 326, 1454, 63, 692, 63, 2489, 29, 797, 12, 1347, 63, 3173, 29, 403, 304, 267, 408, 267, 3033, 26, 881, 1072, 63, 3619, 26, 2082, 370, 5324, 1072, 1584, 14, 881, 2581, 63, 3619, 26, 2082, 1314, 3509, 510, 6084, 18014, 14, 881, 1233, 63, 4679, 26, 1233, 4306, 370, 506, 1202, 14, 881, 2256, 63, 3780, 26, 3931, 13, 6100, 2556, 5022, 14, 881, 1454, 63, 692, 63, 2489, 26, 715, 1380, 314, 6365, 1077, 1454, 2218, 1072, 1584, 288, 1380, 314, 4072, 787, 2896, 14, 881, 1347, 63, 3173, 26, 3931, 370, 506, 7686, 14, 267, 408, 267, 291 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 35, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 12626, 376, 1275, 13398, 570, 370, 699, 1073, 812, 24, 17792, 17048, 72, 436, 1275, 5910, 1584, 680, 199, 199, 20924, 1382, 26, 1455, 921, 1544, 14, 13211, 14, 1308, 15, 23826, 15, 14748, 13, 12233, 15, 13398, 13, 5772, 199, 624, 199, 199, 646, 13022, 199, 504, 8691, 492, 13491, 199, 646, 747, 199, 646, 17572, 465, 5927, 199, 646, 984, 199, 199, 504, 1233, 63, 4679, 63, 86, 24, 492, 5495, 7599, 11728, 4748, 12, 5495, 7599, 54, 24, 12, 5495, 7599, 15540, 804, 199, 504, 20365, 63, 5503, 492, 473, 5030, 5929, 199, 504, 15841, 492, 1218, 63, 3173, 63, 815, 63, 3780, 12, 1586, 63, 13398, 63, 1725, 63, 513, 63, 504, 63, 493, 12, 2218, 63, 493, 12, 20365, 63, 1501, 63, 475, 63, 3173, 421, 199, 318, 2198, 63, 1419, 837, 272, 1798, 275, 13491, 342, 272, 1798, 14, 525, 63, 1422, 4517, 1637, 13, 3619, 297, 1993, 1720, 534, 1637, 2082, 12, 4243, 370, 1072, 2082, 358, 272, 1798, 14, 525, 63, 1422, 4517, 4208, 13, 5472, 297, 1993, 1595, 628, 1617, 63, 2052, 401, 849, 29, 797, 9, 272, 1798, 14, 525, 63, 1422, 4517, 1199, 13, 3619, 358, 272, 1798, 14, 525, 63, 1422, 4517, 5472, 13, 1199, 13, 3619, 358, 272, 1798, 14, 525, 63, 1422, 4517, 815, 13, 694, 358, 272, 1798, 14, 525, 63, 1422, 4517, 952, 13, 493, 13, 2118, 13, 692, 13, 2489, 297, 730, 534, 442, 358, 272, 327, 7600, 26, 2136, 1077, 3544, 7662, 4165, 1553, 1375, 13, 3173, 436, 272, 327, 2813, 314, 849, 5953, 14, 272, 1798, 14, 525, 63, 1422, 4517, 1375, 13, 3173, 297, 1993, 1720, 534, 1375, 3931, 370, 3550, 1233, 12, 4243, 370, 283, 1993, 283, 3173, 402, 1324, 20365, 570, 358, 272, 327, 4868, 1072, 12477, 2061, 12, 880, 1414, 1004, 8837, 370, 2198, 4799, 5163, 397, 272, 1798, 14, 5993, 63, 11005, 529, 939, 63, 589, 342, 339, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 1511, 14, 1199, 63, 3619, 365, 488, 26, 267, 1798, 14, 705, 360, 13757, 4165, 1072, 2082, 1808, 1553, 1199, 13, 3619, 2659, 272, 1511, 14, 952, 63, 493, 63, 2118, 63, 692, 63, 2489, 275, 2155, 8, 1419, 14, 952, 63, 493, 63, 2118, 63, 692, 63, 2489, 9, 272, 340, 822, 8, 589, 9, 1137, 413, 26, 267, 1798, 14, 705, 360, 13757, 4165, 8840, 413, 1324, 570, 465, 1423, 12, 1325, 450, 68, 1627, 3530, 450, 822, 8, 589, 430, 272, 20365, 63, 1501, 275, 747, 14, 515, 14, 11091, 8, 589, 59, 16, 566, 272, 372, 1511, 12, 20365, 63, 1501, 421, 199, 318, 20365, 63, 1501, 63, 475, 63, 3266, 63, 354, 8, 13398, 63, 1501, 304, 272, 9593, 275, 747, 14, 515, 14, 4846, 8, 13398, 63, 1501, 9, 272, 3217, 63, 354, 12, 485, 275, 747, 14, 515, 14, 7973, 8, 4846, 9, 272, 372, 3217, 63, 354, 421, 199, 533, 473, 5030, 9131, 8, 785, 304, 272, 408, 8458, 3523, 8089, 367, 14575, 29784, 14, 339, 1010, 13801, 3992, 26, 272, 627, 291, 14, 600, 63, 4679, 1471, 506, 663, 12, 18234, 3550, 63, 600, 342, 489, 334, 24112, 282, 769, 402, 1072, 1233, 395, 436, 272, 627, 6555, 63, 493, 342, 1471, 506, 6366, 334, 22273, 1072, 6203, 680, 272, 408, 272, 636, 6577, 363, 275, 13022, 14, 22254, 339, 347, 636, 826, 721, 277, 12, 1072, 63, 3619, 12, 2581, 63, 3619, 29, 403, 12, 326, 1233, 63, 4679, 29, 403, 12, 2256, 63, 3780, 29, 403, 12, 326, 1454, 63, 692, 63, 2489, 29, 797, 12, 1347, 63, 3173, 29, 403, 304, 267, 408, 267, 3033, 26, 881, 1072, 63, 3619, 26, 2082, 370, 5324, 1072, 1584, 14, 881, 2581, 63, 3619, 26, 2082, 1314, 3509, 510, 6084, 18014, 14, 881, 1233, 63, 4679, 26, 1233, 4306, 370, 506, 1202, 14, 881, 2256, 63, 3780, 26, 3931, 13, 6100, 2556, 5022, 14, 881, 1454, 63, 692, 63, 2489, 26, 715, 1380, 314, 6365, 1077, 1454, 2218, 1072, 1584, 288, 1380, 314, 4072, 787, 2896, 14, 881, 1347, 63, 3173, 26, 3931, 370, 506, 7686, 14, 267, 408, 267, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
prateeksan/python-design-patterns
structural/adapter.py
1
3485
""" The Adapter Pattern Notes: If the interface of an object does not match the interface required by the client code, this pattern recommends using an 'adapter' that can create a proxy interface. It is particularly useful in homogenizing interfaces of non-homogenous objects. The following example represents a use case for adapting various resource types to be readable as text resources. We assume that the client programmer works with resource objects that wrap binary, web-based or textual data. Each of the aforementioned has its own type and interface but we need to read them all as text type objects. Since every resource type can be represented as text (albeit the method calls to do so vary), we use the TextResourceAdapter to homogenize the interface and output the textual representation using a common read() method (set to behave like the read() method for TextResource). """ class TextResource: """We assume that our server can only read text. Therefore this resource is the only resource the server knows how to interpret. """ def read(self): return "Sample plain text." class BinaryResource: """An instance of this class wraps binary data. While it has many output formats, the server can only read the plain-text output. """ def read_plain_text(self): return "Sample plain text from binary." def read_raw(self): pass def read_interactive(self): pass class WebResource: """An instance of this class wraps web data. While it has many output formats, the server can only read the json output. """ def read_json(self): return "Sample plain text as json." def read_html(self): pass class IncompatibleResourceError(Exception): pass class TextResourceAdapter: """Acts as an adapter that uses the read() method to return a textual representation of the client_resource. """ convertibles = ("TextResource", "BinaryResource", "WebResource") def __init__(self, client_resource): self._verify_compatibility(client_resource) self._client_resource = client_resource def read(self): """Note that for a resource to use the adapter, it needs to be configured beforehand in this method. Your implementation may be modified to change this (depending on your use case). """ if self._client_resource.__class__ is BinaryResource: return self._client_resource.read_plain_text() elif self._client_resource.__class__ is WebResource: return self._client_resource.read_json() return self._client_resource.read() def _verify_compatibility(self, resource): """Since we need to pre-configure the adapter to handle various resource types, we raise an error if the client_resource is not pre-configured. """ if resource.__class__.__name__ not in self.__class__.convertibles: raise IncompatibleResourceError("{} cannot be adapted.".format( resource.__class__.__name__)) if __name__ == "__main__": client_resources = [BinaryResource(), WebResource(), TextResource()] for resource in client_resources: print("Adapting {} as a text resource...".format( resource.__class__.__name__)) adapted_resource = TextResourceAdapter(resource) # Note how the read interface has been homogenized. print(adapted_resource.read() + "\n")
mit
[ 624, 710, 4431, 4185, 27019, 199, 199, 18685, 26, 199, 199, 3917, 314, 3217, 402, 376, 909, 1630, 440, 1336, 314, 3217, 1415, 701, 314, 199, 1258, 1233, 12, 642, 3851, 295, 9847, 795, 1808, 376, 283, 10394, 7, 626, 883, 1218, 282, 4566, 199, 3266, 14, 2779, 365, 6770, 590, 2997, 315, 2636, 573, 2268, 9147, 8386, 402, 221, 199, 2865, 13, 526, 573, 2268, 1785, 2251, 14, 199, 199, 1918, 2569, 2893, 8469, 282, 675, 1930, 367, 1503, 439, 1337, 7750, 2073, 221, 199, 1313, 370, 506, 12701, 465, 1318, 5944, 14, 2136, 5534, 626, 314, 1890, 2240, 2626, 199, 12243, 543, 2073, 2251, 626, 4816, 3366, 12, 3330, 13, 6788, 503, 25884, 666, 14, 7048, 199, 1618, 314, 282, 1707, 32016, 379, 965, 2399, 5705, 730, 436, 3217, 1325, 781, 1929, 370, 1586, 3062, 199, 452, 465, 1318, 730, 2251, 14, 9336, 4036, 2073, 730, 883, 506, 11159, 465, 1318, 199, 8, 279, 1235, 390, 314, 1083, 4882, 370, 886, 880, 17083, 395, 781, 675, 314, 4516, 4031, 10200, 370, 199, 526, 573, 2268, 794, 314, 3217, 436, 1072, 314, 25884, 6025, 1808, 282, 2863, 199, 739, 342, 1083, 334, 409, 370, 24062, 2839, 314, 1586, 342, 1083, 367, 4516, 4031, 680, 199, 199, 624, 199, 199, 533, 4516, 4031, 26, 272, 408, 6004, 5534, 626, 4154, 1654, 883, 1454, 1586, 1318, 14, 21039, 642, 2073, 365, 272, 314, 1454, 2073, 314, 1654, 19428, 4212, 370, 15579, 14, 272, 408, 339, 347, 1586, 8, 277, 304, 267, 372, 298, 8176, 8971, 1318, 2122, 199, 199, 533, 14161, 4031, 26, 272, 408, 2493, 1256, 402, 642, 1021, 14018, 3366, 666, 14, 22117, 652, 965, 5002, 1072, 272, 6752, 12, 314, 1654, 883, 1454, 1586, 314, 8971, 13, 505, 1072, 14, 272, 408, 339, 347, 1586, 63, 6104, 63, 505, 8, 277, 304, 267, 372, 298, 8176, 8971, 1318, 687, 3366, 2122, 339, 347, 1586, 63, 1773, 8, 277, 304, 267, 986, 339, 347, 1586, 63, 13543, 8, 277, 304, 267, 986, 199, 199, 533, 6001, 4031, 26, 272, 408, 2493, 1256, 402, 642, 1021, 14018, 3330, 666, 14, 22117, 652, 965, 5002, 1072, 5591, 6752, 12, 314, 1654, 883, 1454, 1586, 314, 2022, 1072, 14, 272, 408, 339, 347, 1586, 63, 1001, 8, 277, 304, 267, 372, 298, 8176, 8971, 1318, 465, 2022, 2122, 339, 347, 1586, 63, 1360, 8, 277, 304, 267, 986, 199, 199, 533, 1010, 6490, 4031, 547, 8, 1726, 304, 5591, 986, 199, 199, 533, 4516, 4031, 10200, 26, 272, 408, 33, 3021, 465, 376, 12146, 626, 4440, 314, 1586, 342, 1083, 370, 372, 282, 25884, 272, 6025, 402, 314, 1890, 63, 1927, 14, 272, 408, 339, 3818, 21602, 83, 275, 1689, 1872, 4031, 401, 298, 6636, 4031, 401, 298, 5926, 4031, 531, 339, 347, 636, 826, 721, 277, 12, 1890, 63, 1927, 304, 267, 291, 423, 4712, 63, 15390, 8, 1258, 63, 1927, 9, 267, 291, 423, 1258, 63, 1927, 275, 1890, 63, 1927, 339, 347, 1586, 8, 277, 304, 267, 408, 7443, 626, 367, 282, 2073, 370, 675, 314, 12146, 12, 652, 4839, 370, 506, 267, 7526, 2544, 6868, 315, 642, 1083, 14, 19519, 4514, 1443, 506, 267, 6042, 370, 1570, 642, 334, 2601, 3219, 641, 2195, 675, 1930, 680, 267, 408, 398, 340, 291, 423, 1258, 63, 1927, 855, 533, 363, 365, 14161, 4031, 26, 288, 372, 291, 423, 1258, 63, 1927, 14, 739, 63, 6104, 63, 505, 342, 398, 916, 291, 423, 1258, 63, 1927, 855, 533, 363, 365, 6001, 4031, 26, 288, 372, 291, 423, 1258, 63, 1927, 14, 739, 63, 1001, 342, 398, 372, 291, 423, 1258, 63, 1927, 14, 739, 342, 339, 347, 485, 4712, 63, 15390, 8, 277, 12, 2073, 304, 267, 408, 24430, 781, 1929, 370, 876, 13, 6472, 314, 12146, 370, 2429, 7750, 2073, 267, 2943, 12, 781, 746, 376, 1125, 340, 314, 1890, 63, 1927, 365, 440, 876, 13, 11786, 14, 267, 408, 398, 340, 2073, 855, 533, 4914, 354, 363, 440, 315, 291, 855, 533, 4343, 6435, 21602, 83, 26, 288, 746, 1010, 6490, 4031, 547, 20794, 3913, 506, 26266, 15848, 908, 8, 355, 2073, 855, 533, 4914, 354, 8964, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 1890, 63, 4435, 275, 359, 6636, 4031, 1062, 6001, 4031, 1062, 4516, 4031, 5106, 339, 367, 2073, 315, 1890, 63, 4435, 26, 398, 870, 480, 2767, 439, 1337, 1052, 465, 282, 1318, 2073, 1396, 1674, 908, 8, 288, 2073, 855, 533, 4914, 354, 8964, 398, 26266, 63, 1927, 275, 4516, 4031, 10200, 8, 1927, 9, 267, 327, 3390, 4212, 314, 1586, 3217, 965, 2757, 2636, 573, 2268, 1759, 14, 267, 870, 8, 350, 18309, 63, 1927, 14, 739, 342, 435, 1867, 78, 531, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 710, 4431, 4185, 27019, 199, 199, 18685, 26, 199, 199, 3917, 314, 3217, 402, 376, 909, 1630, 440, 1336, 314, 3217, 1415, 701, 314, 199, 1258, 1233, 12, 642, 3851, 295, 9847, 795, 1808, 376, 283, 10394, 7, 626, 883, 1218, 282, 4566, 199, 3266, 14, 2779, 365, 6770, 590, 2997, 315, 2636, 573, 2268, 9147, 8386, 402, 221, 199, 2865, 13, 526, 573, 2268, 1785, 2251, 14, 199, 199, 1918, 2569, 2893, 8469, 282, 675, 1930, 367, 1503, 439, 1337, 7750, 2073, 221, 199, 1313, 370, 506, 12701, 465, 1318, 5944, 14, 2136, 5534, 626, 314, 1890, 2240, 2626, 199, 12243, 543, 2073, 2251, 626, 4816, 3366, 12, 3330, 13, 6788, 503, 25884, 666, 14, 7048, 199, 1618, 314, 282, 1707, 32016, 379, 965, 2399, 5705, 730, 436, 3217, 1325, 781, 1929, 370, 1586, 3062, 199, 452, 465, 1318, 730, 2251, 14, 9336, 4036, 2073, 730, 883, 506, 11159, 465, 1318, 199, 8, 279, 1235, 390, 314, 1083, 4882, 370, 886, 880, 17083, 395, 781, 675, 314, 4516, 4031, 10200, 370, 199, 526, 573, 2268, 794, 314, 3217, 436, 1072, 314, 25884, 6025, 1808, 282, 2863, 199, 739, 342, 1083, 334, 409, 370, 24062, 2839, 314, 1586, 342, 1083, 367, 4516, 4031, 680, 199, 199, 624, 199, 199, 533, 4516, 4031, 26, 272, 408, 6004, 5534, 626, 4154, 1654, 883, 1454, 1586, 1318, 14, 21039, 642, 2073, 365, 272, 314, 1454, 2073, 314, 1654, 19428, 4212, 370, 15579, 14, 272, 408, 339, 347, 1586, 8, 277, 304, 267, 372, 298, 8176, 8971, 1318, 2122, 199, 199, 533, 14161, 4031, 26, 272, 408, 2493, 1256, 402, 642, 1021, 14018, 3366, 666, 14, 22117, 652, 965, 5002, 1072, 272, 6752, 12, 314, 1654, 883, 1454, 1586, 314, 8971, 13, 505, 1072, 14, 272, 408, 339, 347, 1586, 63, 6104, 63, 505, 8, 277, 304, 267, 372, 298, 8176, 8971, 1318, 687, 3366, 2122, 339, 347, 1586, 63, 1773, 8, 277, 304, 267, 986, 339, 347, 1586, 63, 13543, 8, 277, 304, 267, 986, 199, 199, 533, 6001, 4031, 26, 272, 408, 2493, 1256, 402, 642, 1021, 14018, 3330, 666, 14, 22117, 652, 965, 5002, 1072, 5591, 6752, 12, 314, 1654, 883, 1454, 1586, 314, 2022, 1072, 14, 272, 408, 339, 347, 1586, 63, 1001, 8, 277, 304, 267, 372, 298, 8176, 8971, 1318, 465, 2022, 2122, 339, 347, 1586, 63, 1360, 8, 277, 304, 267, 986, 199, 199, 533, 1010, 6490, 4031, 547, 8, 1726, 304, 5591, 986, 199, 199, 533, 4516, 4031, 10200, 26, 272, 408, 33, 3021, 465, 376, 12146, 626, 4440, 314, 1586, 342, 1083, 370, 372, 282, 25884, 272, 6025, 402, 314, 1890, 63, 1927, 14, 272, 408, 339, 3818, 21602, 83, 275, 1689, 1872, 4031, 401, 298, 6636, 4031, 401, 298, 5926, 4031, 531, 339, 347, 636, 826, 721, 277, 12, 1890, 63, 1927, 304, 267, 291, 423, 4712, 63, 15390, 8, 1258, 63, 1927, 9, 267, 291, 423, 1258, 63, 1927, 275, 1890, 63, 1927, 339, 347, 1586, 8, 277, 304, 267, 408, 7443, 626, 367, 282, 2073, 370, 675, 314, 12146, 12, 652, 4839, 370, 506, 267, 7526, 2544, 6868, 315, 642, 1083, 14, 19519, 4514, 1443, 506, 267, 6042, 370, 1570, 642, 334, 2601, 3219, 641, 2195, 675, 1930, 680, 267, 408, 398, 340, 291, 423, 1258, 63, 1927, 855, 533, 363, 365, 14161, 4031, 26, 288, 372, 291, 423, 1258, 63, 1927, 14, 739, 63, 6104, 63, 505, 342, 398, 916, 291, 423, 1258, 63, 1927, 855, 533, 363, 365, 6001, 4031, 26, 288, 372, 291, 423, 1258, 63, 1927, 14, 739, 63, 1001, 342, 398, 372, 291, 423, 1258, 63, 1927, 14, 739, 342, 339, 347, 485, 4712, 63, 15390, 8, 277, 12, 2073, 304, 267, 408, 24430, 781, 1929, 370, 876, 13, 6472, 314, 12146, 370, 2429, 7750, 2073, 267, 2943, 12, 781, 746, 376, 1125, 340, 314, 1890, 63, 1927, 365, 440, 876, 13, 11786, 14, 267, 408, 398, 340, 2073, 855, 533, 4914, 354, 363, 440, 315, 291, 855, 533, 4343, 6435, 21602, 83, 26, 288, 746, 1010, 6490, 4031, 547, 20794, 3913, 506, 26266, 15848, 908, 8, 355, 2073, 855, 533, 4914, 354, 8964, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 1890, 63, 4435, 275, 359, 6636, 4031, 1062, 6001, 4031, 1062, 4516, 4031, 5106, 339, 367, 2073, 315, 1890, 63, 4435, 26, 398, 870, 480, 2767, 439, 1337, 1052, 465, 282, 1318, 2073, 1396, 1674, 908, 8, 288, 2073, 855, 533, 4914, 354, 8964, 398, 26266, 63, 1927, 275, 4516, 4031, 10200, 8, 1927, 9, 267, 327, 3390, 4212, 314, 1586, 3217, 965, 2757, 2636, 573, 2268, 1759, 14, 267, 870, 8, 350, 18309, 63, 1927, 14, 739, 342, 435, 1867, 78, 531, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
3dfxsoftware/cbss-addons
account_aged_partner_balance_report/report/account_aged_partner_balance_report.py
1
10928
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Addons modules by CLEARCORP S.A. # Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import pooler from report import report_sxw from tools.translate import _ from openerp.osv import fields, osv from openerp.addons.account_report_lib.account_report_base import accountReportbase class Parser(accountReportbase): def __init__(self, cr, uid, name, context): super(Parser, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'cr' : cr, 'uid': uid, 'storage':{}, 'set_data_template': self.set_data_template, 'set_data_move_lines': self.set_data_move_lines, 'get_data':self.get_data, 'get_data_by_partner':self.get_data_by_partner, 'get_period_length': self.get_period_length, 'get_direction_selection': self.get_direction_selection, 'display_account_type':self.display_account_type, 'display_direction_selection': self.display_direction_selection, 'display_period_length': self.display_period_length, 'process_lines_period':self.process_lines_period, }) #====Extract data from wizard============================================== def get_period_length(self, data): return self._get_form_param('period_length', data) def get_direction_selection(self, data): return self._get_form_param('direction_selection', data) def get_account_type(self, data): return self._get_form_param('account_type', data) """ Return a dictionary, with this structure: result[account_type][move_list_lines] (a dictionary) """ def get_data_by_partner(self, partner_id): return self.localcontext['storage']['result'][partner_id] #========================================================================== #====Display data========================================================== def display_account_type(self, data=None, account_type=None): #if it's necessary to display in report's header if data: account_type = self.get_account_type(data) ##Options for report information (keys are different) if account_type == 'receivable': return _('Receivable Accounts') elif account_type == 'payable': return _('Payable Accounts') ###Options for header if account_type == 'customer': return _('Receivable accounts') elif account_type == 'supplier': return _('Payable accounts') elif account_type == 'customer_supplier': return _('Payable and Receivable accounts') return '' def display_direction_selection(self, data): direction_selection = self.get_direction_selection(data) if direction_selection == 'past': return _('Past') elif direction_selection == 'future': return _('Future') return '' def display_period_length(self, data): return self.get_period_length(data) #===== Set data ========================================================= #set data to use in odt template. def set_data_template(self, cr, uid, data): result, partner_ids_order = self.get_data(cr, uid, data) dict_update = {'result': result, 'partner_ids_order': partner_ids_order,} self.localcontext['storage'].update(dict_update) return False def set_data_move_lines(self, data, move_lines): #move_lines is a dictionary move_lines, partner_total = self.process_lines_period(data, move_lines) dict_update = {'move_lines':move_lines, 'partner_total':partner_total} self.localcontext['storage'].update(dict_update) return False #========================================================================== def get_move_lines(self, data): account_account_obj = self.pool.get('account.account') account_move_line_obj = self.pool.get('account.move.line') account_type_domain = [] #Get parameters date_from = str(self.get_date_from(data)) direction_selection = str(self.get_direction_selection(data)) account_type = self.get_account_type(data) if account_type == 'customer': account_type_domain.append('receivable') if account_type == 'supplier': account_type_domain.append('payable') if account_type == 'customer_supplier': account_type_domain.append('receivable') account_type_domain.append('payable') #Build domains account_account_ids = account_account_obj.search(self.cr, self.uid, [('type', 'in', account_type_domain), ('active','=',True)]) account_move_line_domain = [('state', '=', 'valid'), ('reconcile_id', '=', False), ('account_id', 'in', account_account_ids)] #=====Build a account move lines domain #Date tuple_date = () if direction_selection == 'past': tuple_date = ('date','<=', date_from) account_move_line_domain.append(tuple_date) else: tuple_date = ('date','>=', date_from) account_move_line_domain.append(tuple_date) #Get move_lines based on previous domain account_move_line_ids = account_move_line_obj.search(self.cr, self.uid, account_move_line_domain, order='date_maturity desc') account_move_lines = account_move_line_obj.browse(self.cr, self.uid, account_move_line_ids) return account_move_lines def get_data(self, cr, uid, data): partner_ids = [] res = {} """ 1. Extract move lines """ move_lines = self.get_move_lines(data) """ 2. Classified move_lines by partner and account_type """ for line in move_lines: if line.partner_id: partner_id = line.partner_id.id else: partner_id = 0 #key for lines that don't have partner_id #== Create a list, them order it by name ============ if partner_id not in partner_ids: partner_ids.append(partner_id) #==================================================== if partner_id not in res.keys(): res[partner_id] = {} if line.account_id.type not in res[partner_id].keys(): res[line.partner_id.id][line.account_id.type] = [] res[partner_id][line.account_id.type].append(line) #Sort by partner's name (alphabetically) partner_ids_order = self.pool.get('res.partner').search(cr, uid, [('id','in', partner_ids)], order='name ASC') partner_list = self.pool.get('res.partner').browse(self.cr, self.uid, partner_ids_order) return res, partner_list #Process each column for line. def process_lines_period(self, data, move_lines): res = {} partner_total = 0.0 result_list = [7] #Get parameters date_from = str(self.get_date_from(data)) direction_selection = str(self.get_direction_selection(data)) for line in move_lines: result_list = map(float, result_list) #initialize list result_list = [0.0 for i in range(7)] if not line.date_maturity or direction_selection == 'past' and line.date_maturity > date_from \ or direction_selection == 'future' and line.date_maturity < date_from: if line.debit: value = line.debit else: value = line.credit result_list[0] = value if line.date_maturity >= data['form']['4']['start'] and line.date_maturity <= data['form']['4']['stop']: if line.debit: value = line.debit else: value = line.credit result_list[1] = value if line.date_maturity >= data['form']['3']['start'] and line.date_maturity <= data['form']['3']['stop']: if line.debit: value = line.debit else: value = line.credit result_list[2] = value if line.date_maturity >= data['form']['2']['start'] and line.date_maturity <= data['form']['2']['stop']: if line.debit: value = line.debit else: value = line.credit result_list[3] = value if line.date_maturity >= data['form']['1']['start'] and line.date_maturity <= data['form']['1']['stop']: if line.debit: value = line.debit else: value = line.credit result_list[4] = value if line.date_maturity and data['form']['0']['stop'] and line.date_maturity <= data['form']['0']['stop'] or line.date_maturity and data['form']['0']['start'] and line.date_maturity >= data['form']['0']['start']: if line.debit: value = line.debit else: value = line.credit result_list[5] = value #Total by partner partner_total += line.debit if line.debit else line.credit * -1 result_list[6] = partner_total res[line.id] = result_list return res, partner_total
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 2654, 4654, 4621, 701, 445, 906, 689, 18650, 48, 428, 14, 33, 14, 199, 3, 259, 1898, 334, 35, 9, 8937, 13, 2566, 11655, 445, 906, 689, 18650, 48, 428, 14, 33, 14, 8642, 1014, 921, 3584, 989, 80, 14, 331, 14, 1556, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 1115, 79, 1435, 199, 504, 3622, 492, 3622, 63, 20851, 199, 504, 7249, 14, 5275, 492, 485, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 504, 5166, 14, 10788, 14, 2048, 63, 3070, 63, 773, 14, 2048, 63, 3070, 63, 1095, 492, 2933, 7457, 1095, 199, 199, 533, 10191, 8, 2048, 7457, 1095, 304, 272, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 2842, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 2728, 291, 14, 17886, 14, 873, 2561, 7205, 283, 1556, 7, 520, 2467, 12, 288, 283, 1535, 356, 1747, 12, 263, 288, 283, 3494, 356, 27125, 288, 283, 409, 63, 576, 63, 1160, 356, 291, 14, 409, 63, 576, 63, 1160, 12, 288, 283, 409, 63, 576, 63, 1185, 63, 1278, 356, 291, 14, 409, 63, 576, 63, 1185, 63, 1278, 12, 288, 283, 362, 63, 576, 356, 277, 14, 362, 63, 576, 12, 259, 288, 283, 362, 63, 576, 63, 991, 63, 3899, 356, 277, 14, 362, 63, 576, 63, 991, 63, 3899, 12, 7205, 283, 362, 63, 5191, 63, 1267, 356, 291, 14, 362, 63, 5191, 63, 1267, 12, 288, 283, 362, 63, 6874, 63, 5592, 356, 291, 14, 362, 63, 6874, 63, 5592, 12, 288, 283, 2918, 63, 2048, 63, 466, 356, 277, 14, 2918, 63, 2048, 63, 466, 12, 288, 283, 2918, 63, 6874, 63, 5592, 356, 291, 14, 2918, 63, 6874, 63, 5592, 12, 7205, 283, 2918, 63, 5191, 63, 1267, 356, 291, 14, 2918, 63, 5191, 63, 1267, 12, 288, 283, 1412, 63, 1278, 63, 5191, 356, 277, 14, 1412, 63, 1278, 63, 5191, 12, 267, 3828, 2286, 327, 532, 12147, 666, 687, 12262, 2486, 17224, 14821, 347, 664, 63, 5191, 63, 1267, 8, 277, 12, 666, 304, 267, 372, 291, 423, 362, 63, 964, 63, 635, 360, 5191, 63, 1267, 297, 666, 9, 2286, 347, 664, 63, 6874, 63, 5592, 8, 277, 12, 666, 304, 267, 372, 291, 423, 362, 63, 964, 63, 635, 360, 6874, 63, 5592, 297, 666, 9, 2286, 347, 664, 63, 2048, 63, 466, 8, 277, 12, 666, 304, 267, 372, 291, 423, 362, 63, 964, 63, 635, 360, 2048, 63, 466, 297, 666, 9, 5493, 408, 267, 1432, 282, 2600, 12, 543, 642, 5523, 26, 267, 754, 59, 2048, 63, 466, 1527, 1185, 63, 513, 63, 1278, 61, 334, 65, 2600, 9, 5591, 408, 272, 347, 664, 63, 576, 63, 991, 63, 3899, 8, 277, 12, 5854, 63, 344, 304, 2126, 372, 291, 14, 17886, 459, 3494, 2545, 1099, 3488, 3899, 63, 344, 61, 5493, 32314, 17575, 2286, 327, 532, 7687, 666, 12813, 17575, 272, 347, 2929, 63, 2048, 63, 466, 8, 277, 12, 666, 29, 403, 12, 2933, 63, 466, 29, 403, 304, 4960, 327, 692, 652, 1159, 5784, 370, 2929, 315, 3622, 1159, 1406, 267, 340, 666, 26, 3777, 288, 2933, 63, 466, 275, 291, 14, 362, 63, 2048, 63, 466, 8, 576, 9, 3777, 2728, 925, 4558, 367, 3622, 2556, 334, 1612, 787, 3365, 9, 4960, 340, 2933, 63, 466, 508, 283, 24890, 461, 356, 288, 372, 4018, 497, 2375, 461, 4473, 6851, 358, 267, 916, 2933, 63, 466, 508, 283, 5989, 461, 356, 288, 372, 4018, 10517, 461, 4473, 6851, 358, 2728, 6754, 4558, 367, 1406, 267, 340, 2933, 63, 466, 508, 283, 10178, 356, 288, 372, 4018, 497, 2375, 461, 12639, 358, 267, 916, 2933, 63, 466, 508, 283, 17294, 356, 288, 372, 4018, 10517, 461, 12639, 358, 267, 916, 2933, 63, 466, 508, 283, 10178, 63, 17294, 356, 288, 372, 4018, 10517, 461, 436, 799, 2375, 461, 12639, 358, 267, 372, 2125, 5493, 347, 2929, 63, 6874, 63, 5592, 8, 277, 12, 666, 304, 267, 7581, 63, 5592, 275, 291, 14, 362, 63, 6874, 63, 5592, 8, 576, 9, 21695, 340, 7581, 63, 5592, 508, 283, 18597, 356, 288, 372, 4018, 48, 1810, 358, 267, 916, 7581, 63, 5592, 508, 283, 2443, 356, 288, 372, 4018, 14224, 358, 4960, 372, 2125, 2286, 347, 2929, 63, 5191, 63, 1267, 8, 277, 12, 666, 304, 267, 372, 291, 14, 362, 63, 5191, 63, 1267, 8, 576, 9, 420, 2043, 272, 327, 19989, 2494, 666, 19691, 763, 272, 327, 409, 666, 370, 675, 315, 312, 3583, 1978, 14, 5591, 347, 663, 63, 576, 63, 1160, 8, 277, 12, 2467, 12, 1747, 12, 666, 304, 18418, 754, 12, 5854, 63, 1580, 63, 1648, 257, 275, 291, 14, 362, 63, 576, 8, 1556, 12, 1747, 12, 666, 9, 267, 1211, 63, 873, 275, 791, 1099, 356, 754, 12, 283, 3899, 63, 1580, 63, 1648, 356, 5854, 63, 1580, 63, 1648, 28209, 18418, 291, 14, 17886, 459, 3494, 2278, 873, 8, 807 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 2654, 4654, 4621, 701, 445, 906, 689, 18650, 48, 428, 14, 33, 14, 199, 3, 259, 1898, 334, 35, 9, 8937, 13, 2566, 11655, 445, 906, 689, 18650, 48, 428, 14, 33, 14, 8642, 1014, 921, 3584, 989, 80, 14, 331, 14, 1556, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 1115, 79, 1435, 199, 504, 3622, 492, 3622, 63, 20851, 199, 504, 7249, 14, 5275, 492, 485, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 504, 5166, 14, 10788, 14, 2048, 63, 3070, 63, 773, 14, 2048, 63, 3070, 63, 1095, 492, 2933, 7457, 1095, 199, 199, 533, 10191, 8, 2048, 7457, 1095, 304, 272, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 2842, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 2728, 291, 14, 17886, 14, 873, 2561, 7205, 283, 1556, 7, 520, 2467, 12, 288, 283, 1535, 356, 1747, 12, 263, 288, 283, 3494, 356, 27125, 288, 283, 409, 63, 576, 63, 1160, 356, 291, 14, 409, 63, 576, 63, 1160, 12, 288, 283, 409, 63, 576, 63, 1185, 63, 1278, 356, 291, 14, 409, 63, 576, 63, 1185, 63, 1278, 12, 288, 283, 362, 63, 576, 356, 277, 14, 362, 63, 576, 12, 259, 288, 283, 362, 63, 576, 63, 991, 63, 3899, 356, 277, 14, 362, 63, 576, 63, 991, 63, 3899, 12, 7205, 283, 362, 63, 5191, 63, 1267, 356, 291, 14, 362, 63, 5191, 63, 1267, 12, 288, 283, 362, 63, 6874, 63, 5592, 356, 291, 14, 362, 63, 6874, 63, 5592, 12, 288, 283, 2918, 63, 2048, 63, 466, 356, 277, 14, 2918, 63, 2048, 63, 466, 12, 288, 283, 2918, 63, 6874, 63, 5592, 356, 291, 14, 2918, 63, 6874, 63, 5592, 12, 7205, 283, 2918, 63, 5191, 63, 1267, 356, 291, 14, 2918, 63, 5191, 63, 1267, 12, 288, 283, 1412, 63, 1278, 63, 5191, 356, 277, 14, 1412, 63, 1278, 63, 5191, 12, 267, 3828, 2286, 327, 532, 12147, 666, 687, 12262, 2486, 17224, 14821, 347, 664, 63, 5191, 63, 1267, 8, 277, 12, 666, 304, 267, 372, 291, 423, 362, 63, 964, 63, 635, 360, 5191, 63, 1267, 297, 666, 9, 2286, 347, 664, 63, 6874, 63, 5592, 8, 277, 12, 666, 304, 267, 372, 291, 423, 362, 63, 964, 63, 635, 360, 6874, 63, 5592, 297, 666, 9, 2286, 347, 664, 63, 2048, 63, 466, 8, 277, 12, 666, 304, 267, 372, 291, 423, 362, 63, 964, 63, 635, 360, 2048, 63, 466, 297, 666, 9, 5493, 408, 267, 1432, 282, 2600, 12, 543, 642, 5523, 26, 267, 754, 59, 2048, 63, 466, 1527, 1185, 63, 513, 63, 1278, 61, 334, 65, 2600, 9, 5591, 408, 272, 347, 664, 63, 576, 63, 991, 63, 3899, 8, 277, 12, 5854, 63, 344, 304, 2126, 372, 291, 14, 17886, 459, 3494, 2545, 1099, 3488, 3899, 63, 344, 61, 5493, 32314, 17575, 2286, 327, 532, 7687, 666, 12813, 17575, 272, 347, 2929, 63, 2048, 63, 466, 8, 277, 12, 666, 29, 403, 12, 2933, 63, 466, 29, 403, 304, 4960, 327, 692, 652, 1159, 5784, 370, 2929, 315, 3622, 1159, 1406, 267, 340, 666, 26, 3777, 288, 2933, 63, 466, 275, 291, 14, 362, 63, 2048, 63, 466, 8, 576, 9, 3777, 2728, 925, 4558, 367, 3622, 2556, 334, 1612, 787, 3365, 9, 4960, 340, 2933, 63, 466, 508, 283, 24890, 461, 356, 288, 372, 4018, 497, 2375, 461, 4473, 6851, 358, 267, 916, 2933, 63, 466, 508, 283, 5989, 461, 356, 288, 372, 4018, 10517, 461, 4473, 6851, 358, 2728, 6754, 4558, 367, 1406, 267, 340, 2933, 63, 466, 508, 283, 10178, 356, 288, 372, 4018, 497, 2375, 461, 12639, 358, 267, 916, 2933, 63, 466, 508, 283, 17294, 356, 288, 372, 4018, 10517, 461, 12639, 358, 267, 916, 2933, 63, 466, 508, 283, 10178, 63, 17294, 356, 288, 372, 4018, 10517, 461, 436, 799, 2375, 461, 12639, 358, 267, 372, 2125, 5493, 347, 2929, 63, 6874, 63, 5592, 8, 277, 12, 666, 304, 267, 7581, 63, 5592, 275, 291, 14, 362, 63, 6874, 63, 5592, 8, 576, 9, 21695, 340, 7581, 63, 5592, 508, 283, 18597, 356, 288, 372, 4018, 48, 1810, 358, 267, 916, 7581, 63, 5592, 508, 283, 2443, 356, 288, 372, 4018, 14224, 358, 4960, 372, 2125, 2286, 347, 2929, 63, 5191, 63, 1267, 8, 277, 12, 666, 304, 267, 372, 291, 14, 362, 63, 5191, 63, 1267, 8, 576, 9, 420, 2043, 272, 327, 19989, 2494, 666, 19691, 763, 272, 327, 409, 666, 370, 675, 315, 312, 3583, 1978, 14, 5591, 347, 663, 63, 576, 63, 1160, 8, 277, 12, 2467, 12, 1747, 12, 666, 304, 18418, 754, 12, 5854, 63, 1580, 63, 1648, 257, 275, 291, 14, 362, 63, 576, 8, 1556, 12, 1747, 12, 666, 9, 267, 1211, 63, 873, 275, 791, 1099, 356, 754, 12, 283, 3899, 63, 1580, 63, 1648, 356, 5854, 63, 1580, 63, 1648, 28209, 18418, 291, 14, 17886, 459, 3494, 2278, 873, 8, 807, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pombredanne/rekall
rekall-core/rekall/plugins/windows/procdump_test.py
4
1746
# Rekall Memory Forensics # # Copyright 2013 Google Inc. All Rights Reserved. # # Authors: # Michael Cohen <scudette@gmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # """Tests for the procexecdump plugins.""" from rekall import testlib class TestProcdump(testlib.HashChecker): """Test the Procdump module.""" PARAMETERS = dict( commandline="procdump --pid %(pid)s --dump_dir %(tempdir)s", pid=2536 ) class TestModDump(testlib.HashChecker): PARAMETERS = dict( commandline="moddump --regex %(driver)s --dump_dir %(tempdir)s", driver="ntoskrnl.exe" ) class TestDLLDump(testlib.HashChecker): """Test the dlldump module.""" PARAMETERS = dict( commandline="dlldump --pid %(pid)s --dump_dir %(tempdir)s", ) class TestPEDump(testlib.HashChecker): PARAMETERS = dict( commandline=("pedump --out_file %(tempdir)s/out_file.exe " "--image_base %(image_base)s"), # This can be fetched from the output of modules plugin. image_base=0xf5fce000, )
gpl-2.0
[ 3, 799, 22360, 15825, 21684, 78, 17378, 199, 3, 199, 3, 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 6642, 26, 199, 3, 16922, 1849, 16800, 665, 551, 3786, 14586, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 199, 3, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 3, 199, 199, 624, 2925, 367, 314, 557, 301, 9542, 2724, 8963, 1041, 199, 504, 295, 22360, 492, 511, 773, 421, 199, 533, 1379, 15019, 2724, 8, 396, 773, 14, 3476, 3048, 304, 272, 408, 774, 314, 29625, 2724, 859, 1041, 339, 23710, 275, 1211, 8, 267, 28279, 628, 4687, 2724, 1553, 3150, 2818, 3150, 9, 83, 1553, 2724, 63, 694, 2818, 11567, 9, 83, 401, 267, 4422, 29, 821, 1344, 267, 776, 421, 199, 533, 1379, 9871, 11772, 8, 396, 773, 14, 3476, 3048, 304, 272, 23710, 275, 1211, 8, 267, 28279, 628, 1494, 2724, 1553, 3821, 2818, 3090, 9, 83, 1553, 2724, 63, 694, 2818, 11567, 9, 83, 401, 267, 5253, 628, 343, 736, 16779, 7530, 14, 5803, 2, 267, 776, 421, 199, 533, 1379, 15982, 11772, 8, 396, 773, 14, 3476, 3048, 304, 272, 408, 774, 314, 17112, 2724, 859, 1041, 339, 23710, 275, 1211, 8, 267, 28279, 628, 9259, 2724, 1553, 3150, 2818, 3150, 9, 83, 1553, 2724, 63, 694, 2818, 11567, 9, 83, 401, 267, 776, 421, 199, 533, 1379, 19359, 1220, 8, 396, 773, 14, 3476, 3048, 304, 272, 23710, 275, 1211, 8, 267, 28279, 15387, 1915, 1220, 1553, 548, 63, 493, 2818, 11567, 9, 83, 15, 548, 63, 493, 14, 5803, 298, 2151, 4320, 1569, 63, 1095, 2818, 1569, 63, 1095, 9, 83, 1288, 398, 327, 961, 883, 506, 19251, 687, 314, 1072, 402, 4621, 3589, 14, 267, 1834, 63, 1095, 29, 16, 1949, 21, 70, 301, 1493, 12, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 799, 22360, 15825, 21684, 78, 17378, 199, 3, 199, 3, 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 6642, 26, 199, 3, 16922, 1849, 16800, 665, 551, 3786, 14586, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 199, 3, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 3, 199, 199, 624, 2925, 367, 314, 557, 301, 9542, 2724, 8963, 1041, 199, 504, 295, 22360, 492, 511, 773, 421, 199, 533, 1379, 15019, 2724, 8, 396, 773, 14, 3476, 3048, 304, 272, 408, 774, 314, 29625, 2724, 859, 1041, 339, 23710, 275, 1211, 8, 267, 28279, 628, 4687, 2724, 1553, 3150, 2818, 3150, 9, 83, 1553, 2724, 63, 694, 2818, 11567, 9, 83, 401, 267, 4422, 29, 821, 1344, 267, 776, 421, 199, 533, 1379, 9871, 11772, 8, 396, 773, 14, 3476, 3048, 304, 272, 23710, 275, 1211, 8, 267, 28279, 628, 1494, 2724, 1553, 3821, 2818, 3090, 9, 83, 1553, 2724, 63, 694, 2818, 11567, 9, 83, 401, 267, 5253, 628, 343, 736, 16779, 7530, 14, 5803, 2, 267, 776, 421, 199, 533, 1379, 15982, 11772, 8, 396, 773, 14, 3476, 3048, 304, 272, 408, 774, 314, 17112, 2724, 859, 1041, 339, 23710, 275, 1211, 8, 267, 28279, 628, 9259, 2724, 1553, 3150, 2818, 3150, 9, 83, 1553, 2724, 63, 694, 2818, 11567, 9, 83, 401, 267, 776, 421, 199, 533, 1379, 19359, 1220, 8, 396, 773, 14, 3476, 3048, 304, 272, 23710, 275, 1211, 8, 267, 28279, 15387, 1915, 1220, 1553, 548, 63, 493, 2818, 11567, 9, 83, 15, 548, 63, 493, 14, 5803, 298, 2151, 4320, 1569, 63, 1095, 2818, 1569, 63, 1095, 9, 83, 1288, 398, 327, 961, 883, 506, 19251, 687, 314, 1072, 402, 4621, 3589, 14, 267, 1834, 63, 1095, 29, 16, 1949, 21, 70, 301, 1493, 12, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nosuchtim/VizBench
src/jsonrpc/jsonrpc.py
1
1044
# Utility to send JSON RPC messages # Avoid the requests module to reduce installation hassles import urllib import urllib2 import json import sys verbose = False def dorpc(port,meth,params): url = 'http://127.0.0.1:%d/api' % (port) id = '12345' data = '{ "jsonrpc": "2.0", "method": "'+meth+'", "params": '+params+', "id":"'+id+'" }\n' req = urllib2.Request(url,data) r = urllib2.urlopen(req) response = r.read() if verbose: print "HTTP status code = ",r.getcode() print "HTTP url = ",r.geturl() print "HTTP info = ",r.info() print "response is ",response j = json.loads(response) if "error" in j: print "ERROR: "+str(j["error"]["message"]) elif "result" in j: print "RESULT: "+str(j["result"]) else: print "No error or result in JSON response!? r="+r if __name__ == '__main__': if len(sys.argv) < 2: print "Usage: jsonrpc {port} {meth} [ {params} ]" else: port = int(sys.argv[1]) meth = sys.argv[2] if len(sys.argv) < 4: params = "{}" else: params = sys.argv[3] dorpc(port,meth,params)
mit
[ 3, 20511, 370, 3222, 4840, 11785, 3788, 199, 199, 3, 19503, 314, 4145, 859, 370, 7114, 12096, 6298, 2978, 199, 646, 4011, 199, 646, 4011, 18, 199, 646, 2022, 199, 646, 984, 199, 199, 3832, 275, 756, 199, 199, 318, 366, 30786, 8, 719, 12, 5247, 12, 1162, 304, 199, 198, 633, 275, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 2689, 68, 15, 1246, 7, 450, 334, 719, 9, 199, 198, 344, 275, 283, 13261, 7, 199, 198, 576, 275, 5041, 298, 31395, 582, 298, 18, 14, 16, 401, 298, 765, 582, 3546, 11, 5247, 11, 4662, 298, 1162, 582, 6681, 1162, 7386, 298, 344, 582, 4507, 11, 344, 11, 4065, 27958, 78, 7, 199, 198, 2103, 275, 4011, 18, 14, 2017, 8, 633, 12, 576, 9, 199, 198, 82, 275, 4011, 18, 14, 10890, 8, 2103, 9, 421, 198, 1310, 275, 519, 14, 739, 342, 421, 198, 692, 3376, 26, 507, 198, 1361, 298, 2856, 2004, 1233, 275, 3872, 82, 14, 362, 600, 342, 507, 198, 1361, 298, 2856, 1166, 275, 3872, 82, 14, 32130, 342, 507, 198, 1361, 298, 2856, 2256, 275, 3872, 82, 14, 815, 342, 507, 198, 1361, 298, 1310, 365, 3872, 1310, 18118, 198, 74, 275, 2022, 14, 3640, 8, 1310, 9, 199, 198, 692, 298, 705, 2, 315, 1335, 26, 507, 198, 1361, 298, 3170, 26, 7210, 495, 8, 74, 905, 705, 6611, 1188, 3135, 199, 198, 4164, 298, 1099, 2, 315, 1335, 26, 507, 198, 1361, 298, 9517, 26, 7210, 495, 8, 74, 905, 1099, 3135, 199, 198, 2836, 26, 507, 198, 1361, 298, 1944, 1125, 503, 754, 315, 4840, 1177, 1, 31, 221, 519, 16368, 82, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 421, 198, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 507, 198, 1361, 298, 7692, 26, 2022, 4354, 469, 719, 93, 469, 5247, 93, 359, 469, 1162, 93, 1622, 2, 199, 198, 2836, 26, 507, 198, 719, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 507, 198, 5247, 275, 984, 14, 3020, 59, 18, 61, 507, 198, 692, 822, 8, 1274, 14, 3020, 9, 665, 841, 26, 686, 198, 1162, 275, 28168, 507, 198, 2836, 26, 686, 198, 1162, 275, 984, 14, 3020, 59, 19, 61, 507, 198, 68, 30786, 8, 719, 12, 5247, 12, 1162, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20511, 370, 3222, 4840, 11785, 3788, 199, 199, 3, 19503, 314, 4145, 859, 370, 7114, 12096, 6298, 2978, 199, 646, 4011, 199, 646, 4011, 18, 199, 646, 2022, 199, 646, 984, 199, 199, 3832, 275, 756, 199, 199, 318, 366, 30786, 8, 719, 12, 5247, 12, 1162, 304, 199, 198, 633, 275, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 2689, 68, 15, 1246, 7, 450, 334, 719, 9, 199, 198, 344, 275, 283, 13261, 7, 199, 198, 576, 275, 5041, 298, 31395, 582, 298, 18, 14, 16, 401, 298, 765, 582, 3546, 11, 5247, 11, 4662, 298, 1162, 582, 6681, 1162, 7386, 298, 344, 582, 4507, 11, 344, 11, 4065, 27958, 78, 7, 199, 198, 2103, 275, 4011, 18, 14, 2017, 8, 633, 12, 576, 9, 199, 198, 82, 275, 4011, 18, 14, 10890, 8, 2103, 9, 421, 198, 1310, 275, 519, 14, 739, 342, 421, 198, 692, 3376, 26, 507, 198, 1361, 298, 2856, 2004, 1233, 275, 3872, 82, 14, 362, 600, 342, 507, 198, 1361, 298, 2856, 1166, 275, 3872, 82, 14, 32130, 342, 507, 198, 1361, 298, 2856, 2256, 275, 3872, 82, 14, 815, 342, 507, 198, 1361, 298, 1310, 365, 3872, 1310, 18118, 198, 74, 275, 2022, 14, 3640, 8, 1310, 9, 199, 198, 692, 298, 705, 2, 315, 1335, 26, 507, 198, 1361, 298, 3170, 26, 7210, 495, 8, 74, 905, 705, 6611, 1188, 3135, 199, 198, 4164, 298, 1099, 2, 315, 1335, 26, 507, 198, 1361, 298, 9517, 26, 7210, 495, 8, 74, 905, 1099, 3135, 199, 198, 2836, 26, 507, 198, 1361, 298, 1944, 1125, 503, 754, 315, 4840, 1177, 1, 31, 221, 519, 16368, 82, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 421, 198, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 507, 198, 1361, 298, 7692, 26, 2022, 4354, 469, 719, 93, 469, 5247, 93, 359, 469, 1162, 93, 1622, 2, 199, 198, 2836, 26, 507, 198, 719, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 507, 198, 5247, 275, 984, 14, 3020, 59, 18, 61, 507, 198, 692, 822, 8, 1274, 14, 3020, 9, 665, 841, 26, 686, 198, 1162, 275, 28168, 507, 198, 2836, 26, 686, 198, 1162, 275, 984, 14, 3020, 59, 19, 61, 507, 198, 68, 30786, 8, 719, 12, 5247, 12, 1162, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pombreda/ruffus
ruffus/test/test_tutorial7.py
1
6147
#!/usr/bin/env python from __future__ import print_function NUMBER_OF_RANDOMS = 10000 CHUNK_SIZE = 1000 working_dir = "temp_tutorial7/" import os import sys # add grandparent to search path for testing grandparent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) sys.path.insert(0, grandparent_dir) # module name = script name without extension module_name = os.path.splitext(os.path.basename(__file__))[0] # funky code to import by file name parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) ruffus_name = os.path.basename(parent_dir) ruffus = __import__ (ruffus_name) for attr in "follows", "split", "mkdir", "files", "transform", "suffix", "posttask", "touch_file", "merge", "Pipeline": globals()[attr] = getattr (ruffus, attr) import random import glob #--------------------------------------------------------------- # # Create random numbers # @follows(mkdir(working_dir)) @files(None, working_dir + "random_numbers.list") def create_random_numbers(input_file_name, output_file_name): f = open(output_file_name, "w") for i in range(NUMBER_OF_RANDOMS): f.write("%g\n" % (random.random() * 100.0)) f.close() #--------------------------------------------------------------- # # Split initial file # @follows(create_random_numbers) @split(working_dir + "random_numbers.list", working_dir + "*.chunks") def step_4_split_numbers_into_chunks (input_file_name, output_files): """ Splits random numbers file into XXX files of CHUNK_SIZE each """ # # clean up files from previous runs # for f in glob.glob("*.chunks"): os.unlink(f) # # create new file every CHUNK_SIZE lines and # copy each line into current file # output_file = None cnt_files = 0 with open(input_file_name) as ii: for i, line in enumerate(ii): if i % CHUNK_SIZE == 0: cnt_files += 1 if output_file: output_file.close() output_file = open(working_dir + "%d.chunks" % cnt_files, "w") output_file.write(line) if output_file: output_file.close() #--------------------------------------------------------------- # # Calculate sum and sum of squares for each chunk file # @transform(step_4_split_numbers_into_chunks, suffix(".chunks"), ".sums") def step_5_calculate_sum_of_squares (input_file_name, output_file_name): with open(output_file_name, "w") as oo: sum_squared, sum = [0.0, 0.0] cnt_values = 0 with open(input_file_name) as ii: for line in ii: cnt_values += 1 val = float(line.rstrip()) sum_squared += val * val sum += val oo.write("%s\n%s\n%d\n" % (repr(sum_squared), repr(sum), cnt_values)) def print_hooray_again(): print(" hooray again") def print_whoppee_again(): print(" whoppee again") #--------------------------------------------------------------- # # Calculate sum and sum of squares for each chunk # @posttask(lambda: sys.stdout.write(" hooray\n")) @posttask(print_hooray_again, print_whoppee_again, touch_file(os.path.join(working_dir, "done"))) @merge(step_5_calculate_sum_of_squares, os.path.join(working_dir, "variance.result")) def step_6_calculate_variance (input_file_names, output_file_name): """ Calculate variance naively """ output = open(output_file_name, "w") # # initialise variables # all_sum_squared = 0.0 all_sum = 0.0 all_cnt_values = 0.0 # # added up all the sum_squared, and sum and cnt_values from all the chunks # for input_file_name in input_file_names: with open(input_file_name) as ii: sum_squared, sum, cnt_values = list(map(float, ii.readlines())) all_sum_squared += sum_squared all_sum += sum all_cnt_values += cnt_values all_mean = all_sum / all_cnt_values variance = (all_sum_squared - all_sum * all_mean)/(all_cnt_values) # # print output # print(variance, file=output) output.close() import unittest, shutil try: from StringIO import StringIO except: from io import StringIO class Test_ruffus(unittest.TestCase): def setUp(self): try: shutil.rmtree(working_dir) except: pass def tearDown(self): try: shutil.rmtree(working_dir) pass except: pass def atest_ruffus (self): pipeline_run(multiprocess = 50, verbose = 0, pipeline= "main") output_file = os.path.join(working_dir, "variance.result") if not os.path.exists (output_file): raise Exception("Missing %s" % output_file) def test_newstyle_ruffus (self): test_pipeline = Pipeline("test") test_pipeline.files(create_random_numbers, None, working_dir + "random_numbers.list")\ .follows(mkdir(working_dir)) test_pipeline.split(task_func = step_4_split_numbers_into_chunks, input = working_dir + "random_numbers.list", output = working_dir + "*.chunks")\ .follows(create_random_numbers) test_pipeline.transform(task_func = step_5_calculate_sum_of_squares, input = step_4_split_numbers_into_chunks, filter = suffix(".chunks"), output = ".sums") test_pipeline.merge(task_func = step_6_calculate_variance, input = step_5_calculate_sum_of_squares, output = os.path.join(working_dir, "variance.result"))\ .posttask(lambda: sys.stdout.write(" hooray\n"))\ .posttask(print_hooray_again, print_whoppee_again, touch_file(os.path.join(working_dir, "done"))) test_pipeline.run(multiprocess = 50, verbose = 0) output_file = os.path.join(working_dir, "variance.result") if not os.path.exists (output_file): raise Exception("Missing %s" % output_file) if __name__ == '__main__': unittest.main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 9190, 63, 3359, 63, 27644, 1649, 3053, 275, 11630, 199, 20512, 63, 4305, 275, 5198, 199, 9818, 63, 694, 275, 298, 808, 63, 23561, 23, 6687, 6905, 199, 646, 747, 199, 646, 984, 199, 199, 3, 1050, 26881, 1708, 370, 2754, 931, 367, 5343, 199, 22655, 1708, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 21777, 401, 21777, 2237, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 26881, 1708, 63, 694, 9, 199, 199, 3, 859, 536, 275, 2884, 536, 1928, 3329, 199, 578, 63, 354, 275, 747, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 3460, 493, 8964, 59, 16, 61, 421, 199, 3, 289, 1778, 89, 1233, 370, 492, 701, 570, 536, 199, 1708, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 21777, 2237, 199, 82, 3043, 527, 63, 354, 275, 747, 14, 515, 14, 4846, 8, 1708, 63, 694, 9, 199, 82, 3043, 527, 275, 636, 646, 363, 334, 82, 3043, 527, 63, 354, 9, 199, 509, 1921, 315, 298, 7207, 83, 401, 298, 1294, 401, 298, 8215, 401, 298, 1725, 401, 298, 4711, 401, 298, 4511, 401, 298, 1932, 1765, 401, 298, 12376, 63, 493, 401, 298, 5628, 401, 298, 17562, 582, 272, 7992, 3430, 962, 61, 275, 2519, 334, 82, 3043, 527, 12, 1921, 9, 199, 199, 646, 2196, 199, 646, 5739, 421, 199, 17807, 18964, 199, 3, 199, 3, 257, 2790, 2196, 5579, 199, 3, 199, 32, 7207, 83, 8, 8215, 8, 9818, 63, 694, 430, 199, 32, 1725, 8, 403, 12, 6449, 63, 694, 435, 298, 2355, 63, 10548, 14, 513, 531, 199, 318, 1218, 63, 2355, 63, 10548, 8, 1210, 63, 493, 63, 354, 12, 1072, 63, 493, 63, 354, 304, 272, 289, 275, 1551, 8, 1199, 63, 493, 63, 354, 12, 298, 87, 531, 272, 367, 284, 315, 1425, 8, 9190, 63, 3359, 63, 27644, 1649, 3053, 304, 267, 289, 14, 952, 3647, 71, 60, 78, 2, 450, 334, 2355, 14, 2355, 342, 627, 2948, 14, 16, 430, 272, 289, 14, 1600, 342, 199, 199, 17807, 18964, 199, 3, 199, 3, 257, 11740, 2536, 570, 199, 3, 199, 32, 7207, 83, 8, 981, 63, 2355, 63, 10548, 9, 199, 32, 1294, 8, 9818, 63, 694, 435, 298, 2355, 63, 10548, 14, 513, 401, 6449, 63, 694, 435, 298, 4856, 10660, 531, 199, 318, 3650, 63, 20, 63, 1294, 63, 10548, 63, 9924, 63, 10660, 334, 1210, 63, 493, 63, 354, 12, 1072, 63, 1725, 304, 272, 408, 267, 11740, 83, 2196, 5579, 570, 1901, 5787, 1584, 402, 6624, 8019, 63, 4305, 1924, 272, 408, 272, 327, 272, 327, 257, 3633, 1536, 1584, 687, 4136, 7858, 272, 327, 272, 367, 289, 315, 5739, 14, 6463, 480, 4856, 10660, 2349, 267, 747, 14, 7162, 8, 70, 9, 272, 327, 272, 327, 257, 1218, 892, 570, 4036, 6624, 8019, 63, 4305, 2385, 436, 272, 327, 755, 1331, 1924, 1004, 1901, 1453, 570, 272, 327, 272, 1072, 63, 493, 275, 488, 272, 12703, 63, 1725, 275, 378, 272, 543, 1551, 8, 1210, 63, 493, 63, 354, 9, 465, 15393, 26, 267, 367, 284, 12, 1004, 315, 3874, 8, 5908, 304, 288, 340, 284, 450, 6624, 8019, 63, 4305, 508, 378, 26, 355, 12703, 63, 1725, 847, 413, 355, 340, 1072, 63, 493, 26, 490, 1072, 63, 493, 14, 1600, 342, 355, 1072, 63, 493, 275, 1551, 8, 9818, 63, 694, 435, 2071, 68, 14, 10660, 2, 450, 12703, 63, 1725, 12, 298, 87, 531, 288, 1072, 63, 493, 14, 952, 8, 604, 9, 272, 340, 1072, 63, 493, 26, 267, 1072, 63, 493, 14, 1600, 342, 199, 199, 17807, 18964, 199, 3, 199, 3, 257, 12707, 3089, 436, 3089, 402, 26170, 367, 1924, 3728, 570, 199, 3, 199, 32, 4711, 8, 2926, 63, 20, 63, 1294, 63, 10548, 63, 9924, 63, 10660, 12, 4739, 9520, 10660, 1288, 3680, 22178, 531, 199, 318, 3650, 63, 21, 63, 12063, 63, 1838, 63, 1618, 63, 20956, 334, 1210, 63, 493, 63, 354, 12, 1072, 63, 493, 63, 354, 304, 272, 543, 1551, 8, 1199, 63, 493, 63, 354, 12, 221, 298, 87, 531, 465, 16390, 26, 267, 3089, 63, 12973, 12, 3089, 275, 359, 16, 14, 16, 12, 378, 14, 16, 61, 267, 12703, 63, 1459, 275, 378, 267, 543, 1551, 8, 1210, 63, 493, 63, 354, 9, 465, 15393, 26, 288, 367, 1004, 315, 15393, 26, 355, 12703, 63, 1459, 847, 413, 355, 1139, 275, 2069, 8, 604, 14, 6735, 1012, 355, 3089, 63, 12973, 847, 1139, 627, 1139, 355, 3089, 847, 1139, 267, 16390, 14, 952, 3647, 83, 60, 78, 5, 83, 60, 78, 5, 68, 60, 78, 2, 450, 334, 2722, 8, 1838, 63, 12973, 395, 4700, 8, 1838, 395, 12703, 63, 1459, 430, 421, 199, 318, 870, 63, 526, 269, 1187, 63, 14199, 837, 272, 870, 480, 258, 2636, 269, 1187, 4020, 531, 199, 199, 318, 870, 63, 2191, 411, 321, 69, 63, 14199, 837, 272, 870, 480, 258, 704, 411, 321, 69, 4020, 531, 421, 199, 17807, 18964, 199, 3, 199, 3, 257, 12707, 3089, 436, 3089, 402, 26170, 367, 1924, 3728, 199, 3, 199, 32, 1932, 1765, 8, 2734, 26, 984, 14, 2703, 14, 952, 480, 258, 2636, 269, 1187, 60, 78, 2237, 199, 32, 1932, 1765, 8, 1361, 63, 526, 269, 1187, 63, 14199, 12, 870, 63, 2191, 411, 321, 69, 63, 14199, 12, 12943, 63, 493, 8, 736, 14, 515, 14, 904, 8, 9818, 63, 694, 12, 298, 4456, 13324, 199, 32, 5628, 8, 2926, 63, 21, 63, 12063, 63, 1838, 63, 1618, 63, 20956, 12, 747, 14, 515, 14, 904, 8, 9818, 63, 694, 12, 298, 6221, 14, 1099, 2237, 199, 318, 3650, 63, 22, 63, 12063, 63, 6221, 334, 1210, 63, 493, 63, 1247, 12, 1072, 63, 493, 63, 354, 304, 272, 408, 272, 12707, 11773, 11802, 1003, 7742, 272, 408, 272, 1072, 275, 1551, 8, 1199, 63, 493, 63, 354 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 9190, 63, 3359, 63, 27644, 1649, 3053, 275, 11630, 199, 20512, 63, 4305, 275, 5198, 199, 9818, 63, 694, 275, 298, 808, 63, 23561, 23, 6687, 6905, 199, 646, 747, 199, 646, 984, 199, 199, 3, 1050, 26881, 1708, 370, 2754, 931, 367, 5343, 199, 22655, 1708, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 21777, 401, 21777, 2237, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 26881, 1708, 63, 694, 9, 199, 199, 3, 859, 536, 275, 2884, 536, 1928, 3329, 199, 578, 63, 354, 275, 747, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 3460, 493, 8964, 59, 16, 61, 421, 199, 3, 289, 1778, 89, 1233, 370, 492, 701, 570, 536, 199, 1708, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 21777, 2237, 199, 82, 3043, 527, 63, 354, 275, 747, 14, 515, 14, 4846, 8, 1708, 63, 694, 9, 199, 82, 3043, 527, 275, 636, 646, 363, 334, 82, 3043, 527, 63, 354, 9, 199, 509, 1921, 315, 298, 7207, 83, 401, 298, 1294, 401, 298, 8215, 401, 298, 1725, 401, 298, 4711, 401, 298, 4511, 401, 298, 1932, 1765, 401, 298, 12376, 63, 493, 401, 298, 5628, 401, 298, 17562, 582, 272, 7992, 3430, 962, 61, 275, 2519, 334, 82, 3043, 527, 12, 1921, 9, 199, 199, 646, 2196, 199, 646, 5739, 421, 199, 17807, 18964, 199, 3, 199, 3, 257, 2790, 2196, 5579, 199, 3, 199, 32, 7207, 83, 8, 8215, 8, 9818, 63, 694, 430, 199, 32, 1725, 8, 403, 12, 6449, 63, 694, 435, 298, 2355, 63, 10548, 14, 513, 531, 199, 318, 1218, 63, 2355, 63, 10548, 8, 1210, 63, 493, 63, 354, 12, 1072, 63, 493, 63, 354, 304, 272, 289, 275, 1551, 8, 1199, 63, 493, 63, 354, 12, 298, 87, 531, 272, 367, 284, 315, 1425, 8, 9190, 63, 3359, 63, 27644, 1649, 3053, 304, 267, 289, 14, 952, 3647, 71, 60, 78, 2, 450, 334, 2355, 14, 2355, 342, 627, 2948, 14, 16, 430, 272, 289, 14, 1600, 342, 199, 199, 17807, 18964, 199, 3, 199, 3, 257, 11740, 2536, 570, 199, 3, 199, 32, 7207, 83, 8, 981, 63, 2355, 63, 10548, 9, 199, 32, 1294, 8, 9818, 63, 694, 435, 298, 2355, 63, 10548, 14, 513, 401, 6449, 63, 694, 435, 298, 4856, 10660, 531, 199, 318, 3650, 63, 20, 63, 1294, 63, 10548, 63, 9924, 63, 10660, 334, 1210, 63, 493, 63, 354, 12, 1072, 63, 1725, 304, 272, 408, 267, 11740, 83, 2196, 5579, 570, 1901, 5787, 1584, 402, 6624, 8019, 63, 4305, 1924, 272, 408, 272, 327, 272, 327, 257, 3633, 1536, 1584, 687, 4136, 7858, 272, 327, 272, 367, 289, 315, 5739, 14, 6463, 480, 4856, 10660, 2349, 267, 747, 14, 7162, 8, 70, 9, 272, 327, 272, 327, 257, 1218, 892, 570, 4036, 6624, 8019, 63, 4305, 2385, 436, 272, 327, 755, 1331, 1924, 1004, 1901, 1453, 570, 272, 327, 272, 1072, 63, 493, 275, 488, 272, 12703, 63, 1725, 275, 378, 272, 543, 1551, 8, 1210, 63, 493, 63, 354, 9, 465, 15393, 26, 267, 367, 284, 12, 1004, 315, 3874, 8, 5908, 304, 288, 340, 284, 450, 6624, 8019, 63, 4305, 508, 378, 26, 355, 12703, 63, 1725, 847, 413, 355, 340, 1072, 63, 493, 26, 490, 1072, 63, 493, 14, 1600, 342, 355, 1072, 63, 493, 275, 1551, 8, 9818, 63, 694, 435, 2071, 68, 14, 10660, 2, 450, 12703, 63, 1725, 12, 298, 87, 531, 288, 1072, 63, 493, 14, 952, 8, 604, 9, 272, 340, 1072, 63, 493, 26, 267, 1072, 63, 493, 14, 1600, 342, 199, 199, 17807, 18964, 199, 3, 199, 3, 257, 12707, 3089, 436, 3089, 402, 26170, 367, 1924, 3728, 570, 199, 3, 199, 32, 4711, 8, 2926, 63, 20, 63, 1294, 63, 10548, 63, 9924, 63, 10660, 12, 4739, 9520, 10660, 1288, 3680, 22178, 531, 199, 318, 3650, 63, 21, 63, 12063, 63, 1838, 63, 1618, 63, 20956, 334, 1210, 63, 493, 63, 354, 12, 1072, 63, 493, 63, 354, 304, 272, 543, 1551, 8, 1199, 63, 493, 63, 354, 12, 221, 298, 87, 531, 465, 16390, 26, 267, 3089, 63, 12973, 12, 3089, 275, 359, 16, 14, 16, 12, 378, 14, 16, 61, 267, 12703, 63, 1459, 275, 378, 267, 543, 1551, 8, 1210, 63, 493, 63, 354, 9, 465, 15393, 26, 288, 367, 1004, 315, 15393, 26, 355, 12703, 63, 1459, 847, 413, 355, 1139, 275, 2069, 8, 604, 14, 6735, 1012, 355, 3089, 63, 12973, 847, 1139, 627, 1139, 355, 3089, 847, 1139, 267, 16390, 14, 952, 3647, 83, 60, 78, 5, 83, 60, 78, 5, 68, 60, 78, 2, 450, 334, 2722, 8, 1838, 63, 12973, 395, 4700, 8, 1838, 395, 12703, 63, 1459, 430, 421, 199, 318, 870, 63, 526, 269, 1187, 63, 14199, 837, 272, 870, 480, 258, 2636, 269, 1187, 4020, 531, 199, 199, 318, 870, 63, 2191, 411, 321, 69, 63, 14199, 837, 272, 870, 480, 258, 704, 411, 321, 69, 4020, 531, 421, 199, 17807, 18964, 199, 3, 199, 3, 257, 12707, 3089, 436, 3089, 402, 26170, 367, 1924, 3728, 199, 3, 199, 32, 1932, 1765, 8, 2734, 26, 984, 14, 2703, 14, 952, 480, 258, 2636, 269, 1187, 60, 78, 2237, 199, 32, 1932, 1765, 8, 1361, 63, 526, 269, 1187, 63, 14199, 12, 870, 63, 2191, 411, 321, 69, 63, 14199, 12, 12943, 63, 493, 8, 736, 14, 515, 14, 904, 8, 9818, 63, 694, 12, 298, 4456, 13324, 199, 32, 5628, 8, 2926, 63, 21, 63, 12063, 63, 1838, 63, 1618, 63, 20956, 12, 747, 14, 515, 14, 904, 8, 9818, 63, 694, 12, 298, 6221, 14, 1099, 2237, 199, 318, 3650, 63, 22, 63, 12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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
azheng51714/PYLearning
scrapy_project/ELEProject/ELEProject/middlewares.py
1
1884
# -*- coding: utf-8 -*- # Define here the models for your spider middleware # # See documentation in: # http://doc.scrapy.org/en/latest/topics/spider-middleware.html from scrapy import signals class EleprojectSpiderMiddleware(object): # Not all methods need to be defined. If a method is not defined, # scrapy acts as if the spider middleware does not modify the # passed objects. @classmethod def from_crawler(cls, crawler): # This method is used by Scrapy to create your spiders. s = cls() crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_spider_input(response, spider): # Called for each response that goes through the spider # middleware and into the spider. # Should return None or raise an exception. return None def process_spider_output(response, result, spider): # Called with the results returned from the Spider, after # it has processed the response. # Must return an iterable of Request, dict or Item objects. for i in result: yield i def process_spider_exception(response, exception, spider): # Called when a spider or process_spider_input() method # (from other spider middleware) raises an exception. # Should return either None or an iterable of Response, dict # or Item objects. pass def process_start_requests(start_requests, spider): # Called with the start requests of the spider, and works # similarly to the process_spider_output() method, except # that it doesn’t have a response associated. # Must return only requests (not items). for r in start_requests: yield r def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 13930, 2348, 314, 1709, 367, 2195, 18094, 10816, 199, 3, 199, 3, 1666, 3794, 315, 26, 199, 3, 1455, 921, 1301, 14, 26442, 14, 1308, 15, 287, 15, 7410, 15, 11299, 15, 12856, 13, 5754, 14, 1360, 199, 199, 504, 18918, 492, 10166, 421, 199, 533, 662, 274, 1715, 25157, 6608, 8, 785, 304, 272, 327, 2832, 1006, 3102, 1929, 370, 506, 3247, 14, 982, 282, 1083, 365, 440, 3247, 12, 272, 327, 18918, 17795, 465, 340, 314, 18094, 10816, 1630, 440, 2811, 314, 272, 327, 3032, 2251, 14, 339, 768, 3744, 272, 347, 687, 63, 23972, 8, 1886, 12, 29550, 304, 267, 327, 961, 1083, 365, 1202, 701, 13916, 345, 647, 370, 1218, 2195, 19441, 7735, 14, 267, 308, 275, 843, 342, 267, 29550, 14, 10458, 14, 2242, 8, 83, 14, 12856, 63, 19234, 12, 4673, 29, 10458, 14, 12856, 63, 19234, 9, 267, 372, 308, 339, 347, 2112, 63, 12856, 63, 1210, 8, 1310, 12, 18094, 304, 267, 327, 12295, 367, 1924, 1177, 626, 13538, 4012, 314, 18094, 267, 327, 10816, 436, 1901, 314, 18094, 14, 398, 327, 7719, 372, 488, 503, 746, 376, 1919, 14, 267, 372, 488, 339, 347, 2112, 63, 12856, 63, 1199, 8, 1310, 12, 754, 12, 18094, 304, 267, 327, 12295, 543, 314, 2058, 2138, 687, 314, 428, 12508, 12, 2410, 267, 327, 652, 965, 7686, 314, 1177, 14, 398, 327, 9498, 372, 376, 6076, 402, 4784, 12, 1211, 503, 7020, 2251, 14, 267, 367, 284, 315, 754, 26, 288, 1995, 284, 339, 347, 2112, 63, 12856, 63, 1971, 8, 1310, 12, 1919, 12, 18094, 304, 267, 327, 12295, 1380, 282, 18094, 503, 2112, 63, 12856, 63, 1210, 342, 1083, 267, 327, 334, 504, 1163, 18094, 10816, 9, 6534, 376, 1919, 14, 398, 327, 7719, 372, 1902, 488, 503, 376, 6076, 402, 7232, 12, 1211, 267, 327, 503, 7020, 2251, 14, 267, 986, 339, 347, 2112, 63, 928, 63, 6615, 8, 928, 63, 6615, 12, 18094, 304, 267, 327, 12295, 543, 314, 1343, 4145, 402, 314, 18094, 12, 436, 5419, 267, 327, 8545, 590, 370, 314, 2112, 63, 12856, 63, 1199, 342, 1083, 12, 871, 267, 327, 626, 652, 3181, 21045, 84, 1172, 282, 1177, 4568, 14, 398, 327, 9498, 372, 1454, 4145, 334, 1397, 2974, 680, 267, 367, 519, 315, 1343, 63, 6615, 26, 288, 1995, 519, 339, 347, 18094, 63, 19234, 8, 277, 12, 18094, 304, 267, 18094, 14, 2921, 14, 815, 360, 25157, 12123, 26, 450, 83, 7, 450, 18094, 14, 354, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 13930, 2348, 314, 1709, 367, 2195, 18094, 10816, 199, 3, 199, 3, 1666, 3794, 315, 26, 199, 3, 1455, 921, 1301, 14, 26442, 14, 1308, 15, 287, 15, 7410, 15, 11299, 15, 12856, 13, 5754, 14, 1360, 199, 199, 504, 18918, 492, 10166, 421, 199, 533, 662, 274, 1715, 25157, 6608, 8, 785, 304, 272, 327, 2832, 1006, 3102, 1929, 370, 506, 3247, 14, 982, 282, 1083, 365, 440, 3247, 12, 272, 327, 18918, 17795, 465, 340, 314, 18094, 10816, 1630, 440, 2811, 314, 272, 327, 3032, 2251, 14, 339, 768, 3744, 272, 347, 687, 63, 23972, 8, 1886, 12, 29550, 304, 267, 327, 961, 1083, 365, 1202, 701, 13916, 345, 647, 370, 1218, 2195, 19441, 7735, 14, 267, 308, 275, 843, 342, 267, 29550, 14, 10458, 14, 2242, 8, 83, 14, 12856, 63, 19234, 12, 4673, 29, 10458, 14, 12856, 63, 19234, 9, 267, 372, 308, 339, 347, 2112, 63, 12856, 63, 1210, 8, 1310, 12, 18094, 304, 267, 327, 12295, 367, 1924, 1177, 626, 13538, 4012, 314, 18094, 267, 327, 10816, 436, 1901, 314, 18094, 14, 398, 327, 7719, 372, 488, 503, 746, 376, 1919, 14, 267, 372, 488, 339, 347, 2112, 63, 12856, 63, 1199, 8, 1310, 12, 754, 12, 18094, 304, 267, 327, 12295, 543, 314, 2058, 2138, 687, 314, 428, 12508, 12, 2410, 267, 327, 652, 965, 7686, 314, 1177, 14, 398, 327, 9498, 372, 376, 6076, 402, 4784, 12, 1211, 503, 7020, 2251, 14, 267, 367, 284, 315, 754, 26, 288, 1995, 284, 339, 347, 2112, 63, 12856, 63, 1971, 8, 1310, 12, 1919, 12, 18094, 304, 267, 327, 12295, 1380, 282, 18094, 503, 2112, 63, 12856, 63, 1210, 342, 1083, 267, 327, 334, 504, 1163, 18094, 10816, 9, 6534, 376, 1919, 14, 398, 327, 7719, 372, 1902, 488, 503, 376, 6076, 402, 7232, 12, 1211, 267, 327, 503, 7020, 2251, 14, 267, 986, 339, 347, 2112, 63, 928, 63, 6615, 8, 928, 63, 6615, 12, 18094, 304, 267, 327, 12295, 543, 314, 1343, 4145, 402, 314, 18094, 12, 436, 5419, 267, 327, 8545, 590, 370, 314, 2112, 63, 12856, 63, 1199, 342, 1083, 12, 871, 267, 327, 626, 652, 3181, 21045, 84, 1172, 282, 1177, 4568, 14, 398, 327, 9498, 372, 1454, 4145, 334, 1397, 2974, 680, 267, 367, 519, 315, 1343, 63, 6615, 26, 288, 1995, 519, 339, 347, 18094, 63, 19234, 8, 277, 12, 18094, 304, 267, 18094, 14, 2921, 14, 815, 360, 25157, 12123, 26, 450, 83, 7, 450, 18094, 14, 354, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
abhitopia/tensorflow
tensorflow/contrib/keras/python/keras/optimizers_test.py
9
3995
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for Keras optimizers.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.contrib.keras.python import keras from tensorflow.contrib.keras.python.keras import testing_utils from tensorflow.python.platform import test def _get_model(input_dim, num_hidden, output_dim): model = keras.models.Sequential() model.add(keras.layers.Dense(num_hidden, activation='relu', input_shape=(input_dim,))) model.add(keras.layers.Dense(output_dim, activation='softmax')) return model def _test_optimizer(optimizer, target=0.75): np.random.seed(1337) (x_train, y_train), _ = testing_utils.get_test_data(train_samples=1000, test_samples=200, input_shape=(10,), num_classes=2) y_train = keras.utils.to_categorical(y_train) model = _get_model(x_train.shape[1], 10, y_train.shape[1]) model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy']) history = model.fit(x_train, y_train, epochs=2, batch_size=16, verbose=0) assert history.history['acc'][-1] >= target config = keras.optimizers.serialize(optimizer) optim = keras.optimizers.deserialize(config) new_config = keras.optimizers.serialize(optim) new_config['class_name'] = new_config['class_name'].lower() assert config == new_config class KerasOptimizersTest(test.TestCase): def test_sgd(self): with self.test_session(): _test_optimizer(keras.optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True)) def test_rmsprop(self): with self.test_session(): _test_optimizer(keras.optimizers.RMSprop()) _test_optimizer(keras.optimizers.RMSprop(decay=1e-3)) def test_adagrad(self): with self.test_session(): _test_optimizer(keras.optimizers.Adagrad()) _test_optimizer(keras.optimizers.Adagrad(decay=1e-3)) def test_adadelta(self): with self.test_session(): _test_optimizer(keras.optimizers.Adadelta(), target=0.6) _test_optimizer(keras.optimizers.Adadelta(decay=1e-3), target=0.6) def test_adam(self): with self.test_session(): _test_optimizer(keras.optimizers.Adam()) _test_optimizer(keras.optimizers.Adam(decay=1e-3)) def test_adamax(self): with self.test_session(): _test_optimizer(keras.optimizers.Adamax()) _test_optimizer(keras.optimizers.Adamax(decay=1e-3)) def test_nadam(self): with self.test_session(): _test_optimizer(keras.optimizers.Nadam()) def test_clipnorm(self): with self.test_session(): _test_optimizer(keras.optimizers.SGD(lr=0.01, momentum=0.9, clipnorm=0.5)) def test_clipvalue(self): with self.test_session(): _test_optimizer(keras.optimizers.SGD(lr=0.01, momentum=0.9, clipvalue=0.5)) if __name__ == '__main__': test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 1804, 30037, 5323, 6315, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 492, 11708, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 14, 8811, 492, 5343, 63, 1208, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 318, 485, 362, 63, 1238, 8, 1210, 63, 3572, 12, 1967, 63, 5642, 12, 1072, 63, 3572, 304, 523, 1402, 275, 11708, 14, 992, 14, 18509, 342, 523, 1402, 14, 525, 8, 8811, 14, 4359, 14, 15327, 8, 1507, 63, 5642, 12, 3044, 10361, 534, 12833, 297, 3044, 1324, 63, 1392, 2687, 1210, 63, 3572, 20097, 523, 1402, 14, 525, 8, 8811, 14, 4359, 14, 15327, 8, 1199, 63, 3572, 12, 10361, 534, 16395, 1333, 523, 372, 1402, 421, 199, 318, 485, 396, 63, 12290, 8, 12290, 12, 1347, 29, 16, 14, 2194, 304, 523, 980, 14, 2355, 14, 5176, 8, 969, 1401, 9, 523, 334, 88, 63, 2834, 12, 612, 63, 2834, 395, 485, 275, 5343, 63, 1208, 14, 362, 63, 396, 63, 576, 8, 2834, 63, 3356, 29, 5279, 12, 10028, 511, 63, 3356, 29, 1840, 12, 10028, 1324, 63, 1392, 2687, 709, 4706, 10028, 1967, 63, 2888, 29, 18, 9, 523, 612, 63, 2834, 275, 11708, 14, 1208, 14, 475, 63, 16810, 8, 89, 63, 2834, 9, 523, 1402, 275, 485, 362, 63, 1238, 8, 88, 63, 2834, 14, 1392, 59, 17, 467, 1616, 12, 612, 63, 2834, 14, 1392, 59, 17, 566, 523, 1402, 14, 2014, 8, 4358, 534, 16810, 63, 20363, 1150, 7537, 297, 355, 10736, 29, 12290, 12, 355, 7186, 2968, 13374, 1105, 523, 7994, 275, 1402, 14, 3269, 8, 88, 63, 2834, 12, 612, 63, 2834, 12, 18463, 29, 18, 12, 3522, 63, 890, 29, 975, 12, 3376, 29, 16, 9, 523, 702, 7994, 14, 5570, 459, 5470, 31942, 17, 61, 2356, 1347, 523, 1101, 275, 11708, 14, 6433, 6315, 14, 3549, 8, 12290, 9, 523, 5323, 275, 11708, 14, 6433, 6315, 14, 11143, 8, 888, 9, 523, 892, 63, 888, 275, 11708, 14, 6433, 6315, 14, 3549, 8, 6433, 9, 523, 892, 63, 888, 459, 533, 63, 354, 418, 275, 892, 63, 888, 459, 533, 63, 354, 2278, 2325, 342, 523, 702, 1101, 508, 892, 63, 888, 421, 199, 533, 1804, 30037, 9867, 6315, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 1226, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 4254, 36, 8, 7493, 29, 16, 14, 614, 12, 5644, 23887, 29, 16, 14, 25, 12, 5644, 302, 397, 24208, 86, 29, 549, 430, 819, 347, 511, 63, 24444, 4469, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 50, 3053, 4469, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 50, 3053, 4469, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 350, 27707, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 2767, 27707, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 2767, 27707, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 10641, 3136, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 3136, 1062, 1347, 29, 16, 14, 22, 9, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 3136, 8, 16889, 29, 17, 69, 13, 19, 395, 1347, 29, 16, 14, 22, 9, 819, 347, 511, 63, 27679, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 32408, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 32408, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 10641, 988, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 988, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 988, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 78, 27679, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 46, 27679, 1012, 819, 347, 511, 63, 7548, 4791, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 4254, 36, 8, 7493, 29, 16, 14, 614, 12, 5644, 23887, 29, 16, 14, 25, 12, 5644, 11353, 4791, 29, 16, 14, 21, 430, 819, 347, 511, 63, 7548, 585, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 4254, 36, 8, 7493, 29, 16, 14, 614, 12, 5644, 23887, 29, 16, 14, 25, 12, 5644, 11353, 585, 29, 16, 14, 21, 430 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 1804, 30037, 5323, 6315, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 492, 11708, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 14, 8811, 492, 5343, 63, 1208, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 318, 485, 362, 63, 1238, 8, 1210, 63, 3572, 12, 1967, 63, 5642, 12, 1072, 63, 3572, 304, 523, 1402, 275, 11708, 14, 992, 14, 18509, 342, 523, 1402, 14, 525, 8, 8811, 14, 4359, 14, 15327, 8, 1507, 63, 5642, 12, 3044, 10361, 534, 12833, 297, 3044, 1324, 63, 1392, 2687, 1210, 63, 3572, 20097, 523, 1402, 14, 525, 8, 8811, 14, 4359, 14, 15327, 8, 1199, 63, 3572, 12, 10361, 534, 16395, 1333, 523, 372, 1402, 421, 199, 318, 485, 396, 63, 12290, 8, 12290, 12, 1347, 29, 16, 14, 2194, 304, 523, 980, 14, 2355, 14, 5176, 8, 969, 1401, 9, 523, 334, 88, 63, 2834, 12, 612, 63, 2834, 395, 485, 275, 5343, 63, 1208, 14, 362, 63, 396, 63, 576, 8, 2834, 63, 3356, 29, 5279, 12, 10028, 511, 63, 3356, 29, 1840, 12, 10028, 1324, 63, 1392, 2687, 709, 4706, 10028, 1967, 63, 2888, 29, 18, 9, 523, 612, 63, 2834, 275, 11708, 14, 1208, 14, 475, 63, 16810, 8, 89, 63, 2834, 9, 523, 1402, 275, 485, 362, 63, 1238, 8, 88, 63, 2834, 14, 1392, 59, 17, 467, 1616, 12, 612, 63, 2834, 14, 1392, 59, 17, 566, 523, 1402, 14, 2014, 8, 4358, 534, 16810, 63, 20363, 1150, 7537, 297, 355, 10736, 29, 12290, 12, 355, 7186, 2968, 13374, 1105, 523, 7994, 275, 1402, 14, 3269, 8, 88, 63, 2834, 12, 612, 63, 2834, 12, 18463, 29, 18, 12, 3522, 63, 890, 29, 975, 12, 3376, 29, 16, 9, 523, 702, 7994, 14, 5570, 459, 5470, 31942, 17, 61, 2356, 1347, 523, 1101, 275, 11708, 14, 6433, 6315, 14, 3549, 8, 12290, 9, 523, 5323, 275, 11708, 14, 6433, 6315, 14, 11143, 8, 888, 9, 523, 892, 63, 888, 275, 11708, 14, 6433, 6315, 14, 3549, 8, 6433, 9, 523, 892, 63, 888, 459, 533, 63, 354, 418, 275, 892, 63, 888, 459, 533, 63, 354, 2278, 2325, 342, 523, 702, 1101, 508, 892, 63, 888, 421, 199, 533, 1804, 30037, 9867, 6315, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 1226, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 4254, 36, 8, 7493, 29, 16, 14, 614, 12, 5644, 23887, 29, 16, 14, 25, 12, 5644, 302, 397, 24208, 86, 29, 549, 430, 819, 347, 511, 63, 24444, 4469, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 50, 3053, 4469, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 50, 3053, 4469, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 350, 27707, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 2767, 27707, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 2767, 27707, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 10641, 3136, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 3136, 1062, 1347, 29, 16, 14, 22, 9, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 3136, 8, 16889, 29, 17, 69, 13, 19, 395, 1347, 29, 16, 14, 22, 9, 819, 347, 511, 63, 27679, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 32408, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 32408, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 10641, 988, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 988, 1012, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 33, 983, 988, 8, 16889, 29, 17, 69, 13, 19, 430, 819, 347, 511, 63, 78, 27679, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 46, 27679, 1012, 819, 347, 511, 63, 7548, 4791, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 485, 396, 63, 12290, 8, 8811, 14, 6433, 6315, 14, 4254, 36, 8, 7493, 29, 16, 14, 614, 12, 5644, 23887, 29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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
krafczyk/spack
var/spack/repos/builtin/packages/py-poster/package.py
5
1592
############################################################################## # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-647188 # # For details, see https://github.com/spack/spack # Please also see the NOTICE and LICENSE files for our notice and the LGPL. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (as # published by the Free Software Foundation) version 2.1, February 1999. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and # conditions of the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * class PyPoster(PythonPackage): """Streaming HTTP uploads and multipart/form-data encoding.""" homepage = "https://pypi.org/project/poster/" url = "https://atlee.ca/software/poster/dist/0.8.1/poster-0.8.1.tar.gz" version('0.8.1', '2db12704538781fbaa7e63f1505d6fc8') depends_on('py-setuptools', type='build')
lgpl-2.1
[ 4605, 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 1611, 6981, 351, 8, 4718, 8599, 304, 272, 408, 22555, 3101, 26598, 436, 15193, 15, 964, 13, 576, 2644, 1041, 339, 26586, 275, 298, 2859, 921, 17343, 14, 1308, 15, 1715, 15, 20801, 6687, 272, 1166, 420, 275, 298, 2859, 921, 292, 18387, 14, 696, 15, 15619, 15, 20801, 15, 2686, 15, 16, 14, 24, 14, 17, 15, 20801, 13, 16, 14, 24, 14, 17, 14, 5369, 14, 6838, 2, 339, 1015, 360, 16, 14, 24, 14, 17, 297, 283, 18, 697, 4195, 966, 2481, 1555, 2835, 4675, 2158, 23, 69, 2766, 70, 1046, 1717, 68, 22, 3003, 24, 358, 339, 8350, 63, 265, 360, 647, 13, 13623, 297, 730, 534, 1506, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 1611, 6981, 351, 8, 4718, 8599, 304, 272, 408, 22555, 3101, 26598, 436, 15193, 15, 964, 13, 576, 2644, 1041, 339, 26586, 275, 298, 2859, 921, 17343, 14, 1308, 15, 1715, 15, 20801, 6687, 272, 1166, 420, 275, 298, 2859, 921, 292, 18387, 14, 696, 15, 15619, 15, 20801, 15, 2686, 15, 16, 14, 24, 14, 17, 15, 20801, 13, 16, 14, 24, 14, 17, 14, 5369, 14, 6838, 2, 339, 1015, 360, 16, 14, 24, 14, 17, 297, 283, 18, 697, 4195, 966, 2481, 1555, 2835, 4675, 2158, 23, 69, 2766, 70, 1046, 1717, 68, 22, 3003, 24, 358, 339, 8350, 63, 265, 360, 647, 13, 13623, 297, 730, 534, 1506, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bow/bioconda-recipes
recipes/biopet-seqstat/biopet-seqstat.py
44
3365
#!/usr/bin/env python # # Wrapper script for starting the biopet-seqstat JAR package # # This script is written for use with the Conda package manager and is copied # from the peptide-shaker wrapper. Only the parameters are changed. # (https://github.com/bioconda/bioconda-recipes/blob/master/recipes/peptide-shaker/peptide-shaker.py) # # This file was automatically generated by the sbt-bioconda plugin. import os import subprocess import sys import shutil from os import access from os import getenv from os import X_OK jar_file = 'seqstat-assembly-1.0.jar' default_jvm_mem_opts = [] # !!! End of parameter section. No user-serviceable code below this line !!! def real_dirname(path): """Return the symlink-resolved, canonicalized directory-portion of path.""" return os.path.dirname(os.path.realpath(path)) def java_executable(): """Return the executable name of the Java interpreter.""" java_home = getenv('JAVA_HOME') java_bin = os.path.join('bin', 'java') if java_home and access(os.path.join(java_home, java_bin), X_OK): return os.path.join(java_home, java_bin) else: return 'java' def jvm_opts(argv): """Construct list of Java arguments based on our argument list. The argument list passed in argv must not include the script name. The return value is a 3-tuple lists of strings of the form: (memory_options, prop_options, passthrough_options) """ mem_opts = [] prop_opts = [] pass_args = [] exec_dir = None for arg in argv: if arg.startswith('-D'): prop_opts.append(arg) elif arg.startswith('-XX'): prop_opts.append(arg) elif arg.startswith('-Xm'): mem_opts.append(arg) elif arg.startswith('--exec_dir='): exec_dir = arg.split('=')[1].strip('"').strip("'") if not os.path.exists(exec_dir): shutil.copytree(real_dirname(sys.argv[0]), exec_dir, symlinks=False, ignore=None) else: pass_args.append(arg) # In the original shell script the test coded below read: # if [ "$jvm_mem_opts" == "" ] && [ -z ${_JAVA_OPTIONS+x} ] # To reproduce the behaviour of the above shell code fragment # it is important to explictly check for equality with None # in the second condition, so a null envar value counts as True! if mem_opts == [] and getenv('_JAVA_OPTIONS') is None: mem_opts = default_jvm_mem_opts return (mem_opts, prop_opts, pass_args, exec_dir) def main(): """ PeptideShaker updates files relative to the path of the jar file. In a multiuser setting, the option --exec_dir="exec_dir" can be used as the location for the peptide-shaker distribution. If the exec_dir dies not exist, we copy the jar file, lib, and resources to the exec_dir directory. """ java = java_executable() (mem_opts, prop_opts, pass_args, exec_dir) = jvm_opts(sys.argv[1:]) jar_dir = exec_dir if exec_dir else real_dirname(sys.argv[0]) if pass_args != [] and pass_args[0].startswith('eu'): jar_arg = '-cp' else: jar_arg = '-jar' jar_path = os.path.join(jar_dir, jar_file) java_args = [java] + mem_opts + prop_opts + [jar_arg] + [jar_path] + pass_args sys.exit(subprocess.call(java_args)) if __name__ == '__main__': main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 21947, 2884, 367, 6617, 314, 28897, 8096, 13, 3610, 3736, 1603, 689, 2559, 199, 3, 199, 3, 961, 2884, 365, 5313, 367, 675, 543, 314, 1448, 983, 2559, 5256, 436, 365, 8876, 199, 3, 687, 314, 22602, 280, 271, 13, 25880, 4975, 14, 5972, 314, 2633, 787, 2896, 14, 199, 3, 334, 2859, 921, 5031, 14, 957, 15, 17614, 23463, 15, 17614, 23463, 13, 25200, 15, 6582, 15, 4133, 15, 25200, 15, 12636, 280, 271, 13, 25880, 15, 12636, 280, 271, 13, 25880, 14, 647, 9, 199, 3, 199, 3, 961, 570, 1990, 5847, 4046, 701, 314, 308, 13061, 13, 17614, 23463, 3589, 14, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 646, 5145, 199, 199, 504, 747, 492, 2879, 199, 504, 747, 492, 29626, 199, 504, 747, 492, 1323, 63, 3593, 199, 199, 7338, 63, 493, 275, 283, 3610, 3736, 13, 17828, 13, 17, 14, 16, 14, 7338, 7, 199, 199, 885, 63, 15813, 63, 5286, 63, 3291, 275, 942, 199, 199, 3, 221, 21512, 9599, 402, 2725, 3420, 14, 3091, 922, 13, 1364, 461, 1233, 5084, 642, 1004, 221, 21512, 398, 199, 318, 3363, 63, 3475, 8, 515, 304, 272, 408, 1767, 314, 15296, 13, 13697, 12, 11358, 1759, 2082, 13, 7314, 296, 402, 931, 1041, 272, 372, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 8, 515, 430, 421, 199, 318, 12120, 63, 5904, 837, 272, 408, 1767, 314, 7286, 536, 402, 314, 9586, 12693, 1041, 272, 12120, 63, 4219, 275, 29626, 360, 42, 28520, 63, 9524, 358, 272, 12120, 63, 1393, 275, 747, 14, 515, 14, 904, 360, 1393, 297, 283, 6138, 358, 339, 340, 12120, 63, 4219, 436, 2879, 8, 736, 14, 515, 14, 904, 8, 6138, 63, 4219, 12, 12120, 63, 1393, 395, 1323, 63, 3593, 304, 267, 372, 747, 14, 515, 14, 904, 8, 6138, 63, 4219, 12, 12120, 63, 1393, 9, 272, 587, 26, 267, 372, 283, 6138, 7, 421, 199, 318, 1335, 2611, 63, 3291, 8, 3020, 304, 272, 408, 11493, 769, 402, 9586, 2368, 4079, 641, 4154, 1423, 769, 14, 339, 710, 1423, 769, 3032, 315, 9238, 1471, 440, 2387, 314, 2884, 536, 14, 272, 710, 372, 574, 365, 282, 650, 13, 2960, 5548, 402, 3326, 402, 314, 1824, 26, 489, 334, 4844, 63, 1419, 12, 5931, 63, 1419, 12, 19099, 20887, 63, 1419, 9, 272, 408, 272, 7573, 63, 3291, 275, 942, 272, 5931, 63, 3291, 275, 942, 272, 986, 63, 589, 275, 942, 272, 2146, 63, 694, 275, 488, 339, 367, 1680, 315, 9238, 26, 267, 340, 1680, 14, 2460, 3654, 36, 735, 288, 5931, 63, 3291, 14, 740, 8, 1273, 9, 267, 916, 1680, 14, 2460, 3654, 2483, 735, 288, 5931, 63, 3291, 14, 740, 8, 1273, 9, 267, 916, 1680, 14, 2460, 3654, 56, 77, 735, 288, 7573, 63, 3291, 14, 740, 8, 1273, 9, 267, 916, 1680, 14, 2460, 4517, 1628, 63, 694, 534, 304, 288, 2146, 63, 694, 275, 1680, 14, 1294, 26800, 5832, 17, 1055, 1913, 14088, 1959, 1913, 480, 9859, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 1628, 63, 694, 304, 355, 5145, 14, 29296, 8, 3093, 63, 3475, 8, 1274, 14, 3020, 59, 16, 2522, 2146, 63, 694, 12, 19891, 29, 797, 12, 3686, 29, 403, 9, 267, 587, 26, 288, 986, 63, 589, 14, 740, 8, 1273, 9, 339, 327, 1010, 314, 3379, 5218, 2884, 314, 511, 1233, 68, 5084, 1586, 26, 272, 327, 257, 340, 359, 7880, 15813, 63, 5286, 63, 3291, 2, 508, 3087, 1622, 10883, 359, 446, 90, 10839, 63, 42, 28520, 63, 8808, 11, 88, 93, 1622, 272, 327, 4005, 9172, 314, 13942, 402, 314, 3432, 5218, 1233, 7956, 272, 327, 652, 365, 11012, 370, 1437, 6960, 590, 1104, 367, 16612, 543, 488, 272, 327, 315, 314, 3499, 5558, 12, 880, 282, 2973, 655, 1391, 574, 8242, 465, 715, 1, 339, 340, 7573, 63, 3291, 508, 942, 436, 29626, 6412, 42, 28520, 63, 8808, 358, 365, 488, 26, 267, 7573, 63, 3291, 275, 849, 63, 15813, 63, 5286, 63, 3291, 339, 372, 334, 5286, 63, 3291, 12, 5931, 63, 3291, 12, 986, 63, 589, 12, 2146, 63, 694, 9, 421, 199, 318, 2446, 837, 272, 408, 272, 510, 1545, 280, 271, 2662, 12630, 7029, 1584, 3847, 370, 314, 931, 402, 314, 16290, 570, 14, 272, 1010, 282, 3510, 751, 4260, 12, 314, 945, 1553, 1628, 63, 694, 628, 1628, 63, 694, 2, 272, 883, 506, 1202, 465, 314, 2909, 367, 314, 22602, 280, 271, 13, 25880, 4084, 14, 272, 982, 314, 2146, 63, 694, 487, 397, 440, 2187, 12, 272, 781, 1331, 314, 16290, 570, 12, 1973, 12, 436, 5944, 370, 314, 2146, 63, 694, 2082, 14, 272, 408, 272, 12120, 275, 12120, 63, 5904, 342, 272, 334, 5286, 63, 3291, 12, 5931, 63, 3291, 12, 986, 63, 589, 12, 2146, 63, 694, 9, 275, 1335, 2611, 63, 3291, 8, 1274, 14, 3020, 59, 17, 5728, 272, 16290, 63, 694, 275, 2146, 63, 694, 340, 2146, 63, 694, 587, 3363, 63, 3475, 8, 1274, 14, 3020, 59, 16, 566, 339, 340, 986, 63, 589, 1137, 942, 436, 986, 63, 589, 59, 16, 1055, 2460, 360, 16913, 735, 267, 16290, 63, 1273, 275, 2475, 1850, 7, 272, 587, 26, 267, 16290, 63, 1273, 275, 2475, 7338, 7, 339, 16290, 63, 515, 275, 747, 14, 515, 14, 904, 8, 7338, 63, 694, 12, 16290, 63, 493, 9, 339, 12120, 63, 589, 275, 359, 6138, 61, 435, 7573, 63, 3291, 435, 5931, 63, 3291, 435, 359, 7338, 63, 1273, 61, 435, 359, 7338, 63, 515, 61, 435, 986, 63, 589, 339, 984, 14, 2224, 8, 5781, 14, 1250, 8, 6138, 63, 589, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 21947, 2884, 367, 6617, 314, 28897, 8096, 13, 3610, 3736, 1603, 689, 2559, 199, 3, 199, 3, 961, 2884, 365, 5313, 367, 675, 543, 314, 1448, 983, 2559, 5256, 436, 365, 8876, 199, 3, 687, 314, 22602, 280, 271, 13, 25880, 4975, 14, 5972, 314, 2633, 787, 2896, 14, 199, 3, 334, 2859, 921, 5031, 14, 957, 15, 17614, 23463, 15, 17614, 23463, 13, 25200, 15, 6582, 15, 4133, 15, 25200, 15, 12636, 280, 271, 13, 25880, 15, 12636, 280, 271, 13, 25880, 14, 647, 9, 199, 3, 199, 3, 961, 570, 1990, 5847, 4046, 701, 314, 308, 13061, 13, 17614, 23463, 3589, 14, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 646, 5145, 199, 199, 504, 747, 492, 2879, 199, 504, 747, 492, 29626, 199, 504, 747, 492, 1323, 63, 3593, 199, 199, 7338, 63, 493, 275, 283, 3610, 3736, 13, 17828, 13, 17, 14, 16, 14, 7338, 7, 199, 199, 885, 63, 15813, 63, 5286, 63, 3291, 275, 942, 199, 199, 3, 221, 21512, 9599, 402, 2725, 3420, 14, 3091, 922, 13, 1364, 461, 1233, 5084, 642, 1004, 221, 21512, 398, 199, 318, 3363, 63, 3475, 8, 515, 304, 272, 408, 1767, 314, 15296, 13, 13697, 12, 11358, 1759, 2082, 13, 7314, 296, 402, 931, 1041, 272, 372, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 8, 515, 430, 421, 199, 318, 12120, 63, 5904, 837, 272, 408, 1767, 314, 7286, 536, 402, 314, 9586, 12693, 1041, 272, 12120, 63, 4219, 275, 29626, 360, 42, 28520, 63, 9524, 358, 272, 12120, 63, 1393, 275, 747, 14, 515, 14, 904, 360, 1393, 297, 283, 6138, 358, 339, 340, 12120, 63, 4219, 436, 2879, 8, 736, 14, 515, 14, 904, 8, 6138, 63, 4219, 12, 12120, 63, 1393, 395, 1323, 63, 3593, 304, 267, 372, 747, 14, 515, 14, 904, 8, 6138, 63, 4219, 12, 12120, 63, 1393, 9, 272, 587, 26, 267, 372, 283, 6138, 7, 421, 199, 318, 1335, 2611, 63, 3291, 8, 3020, 304, 272, 408, 11493, 769, 402, 9586, 2368, 4079, 641, 4154, 1423, 769, 14, 339, 710, 1423, 769, 3032, 315, 9238, 1471, 440, 2387, 314, 2884, 536, 14, 272, 710, 372, 574, 365, 282, 650, 13, 2960, 5548, 402, 3326, 402, 314, 1824, 26, 489, 334, 4844, 63, 1419, 12, 5931, 63, 1419, 12, 19099, 20887, 63, 1419, 9, 272, 408, 272, 7573, 63, 3291, 275, 942, 272, 5931, 63, 3291, 275, 942, 272, 986, 63, 589, 275, 942, 272, 2146, 63, 694, 275, 488, 339, 367, 1680, 315, 9238, 26, 267, 340, 1680, 14, 2460, 3654, 36, 735, 288, 5931, 63, 3291, 14, 740, 8, 1273, 9, 267, 916, 1680, 14, 2460, 3654, 2483, 735, 288, 5931, 63, 3291, 14, 740, 8, 1273, 9, 267, 916, 1680, 14, 2460, 3654, 56, 77, 735, 288, 7573, 63, 3291, 14, 740, 8, 1273, 9, 267, 916, 1680, 14, 2460, 4517, 1628, 63, 694, 534, 304, 288, 2146, 63, 694, 275, 1680, 14, 1294, 26800, 5832, 17, 1055, 1913, 14088, 1959, 1913, 480, 9859, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 1628, 63, 694, 304, 355, 5145, 14, 29296, 8, 3093, 63, 3475, 8, 1274, 14, 3020, 59, 16, 2522, 2146, 63, 694, 12, 19891, 29, 797, 12, 3686, 29, 403, 9, 267, 587, 26, 288, 986, 63, 589, 14, 740, 8, 1273, 9, 339, 327, 1010, 314, 3379, 5218, 2884, 314, 511, 1233, 68, 5084, 1586, 26, 272, 327, 257, 340, 359, 7880, 15813, 63, 5286, 63, 3291, 2, 508, 3087, 1622, 10883, 359, 446, 90, 10839, 63, 42, 28520, 63, 8808, 11, 88, 93, 1622, 272, 327, 4005, 9172, 314, 13942, 402, 314, 3432, 5218, 1233, 7956, 272, 327, 652, 365, 11012, 370, 1437, 6960, 590, 1104, 367, 16612, 543, 488, 272, 327, 315, 314, 3499, 5558, 12, 880, 282, 2973, 655, 1391, 574, 8242, 465, 715, 1, 339, 340, 7573, 63, 3291, 508, 942, 436, 29626, 6412, 42, 28520, 63, 8808, 358, 365, 488, 26, 267, 7573, 63, 3291, 275, 849, 63, 15813, 63, 5286, 63, 3291, 339, 372, 334, 5286, 63, 3291, 12, 5931, 63, 3291, 12, 986, 63, 589, 12, 2146, 63, 694, 9, 421, 199, 318, 2446, 837, 272, 408, 272, 510, 1545, 280, 271, 2662, 12630, 7029, 1584, 3847, 370, 314, 931, 402, 314, 16290, 570, 14, 272, 1010, 282, 3510, 751, 4260, 12, 314, 945, 1553, 1628, 63, 694, 628, 1628, 63, 694, 2, 272, 883, 506, 1202, 465, 314, 2909, 367, 314, 22602, 280, 271, 13, 25880, 4084, 14, 272, 982, 314, 2146, 63, 694, 487, 397, 440, 2187, 12, 272, 781, 1331, 314, 16290, 570, 12, 1973, 12, 436, 5944, 370, 314, 2146, 63, 694, 2082, 14, 272, 408, 272, 12120, 275, 12120, 63, 5904, 342, 272, 334, 5286, 63, 3291, 12, 5931, 63, 3291, 12, 986, 63, 589, 12, 2146, 63, 694, 9, 275, 1335, 2611, 63, 3291, 8, 1274, 14, 3020, 59, 17, 5728, 272, 16290, 63, 694, 275, 2146, 63, 694, 340, 2146, 63, 694, 587, 3363, 63, 3475, 8, 1274, 14, 3020, 59, 16, 566, 339, 340, 986, 63, 589, 1137, 942, 436, 986, 63, 589, 59, 16, 1055, 2460, 360, 16913, 735, 267, 16290, 63, 1273, 275, 2475, 1850, 7, 272, 587, 26, 267, 16290, 63, 1273, 275, 2475, 7338, 7, 339, 16290, 63, 515, 275, 747, 14, 515, 14, 904, 8, 7338, 63, 694, 12, 16290, 63, 493, 9, 339, 12120, 63, 589, 275, 359, 6138, 61, 435, 7573, 63, 3291, 435, 5931, 63, 3291, 435, 359, 7338, 63, 1273, 61, 435, 359, 7338, 63, 515, 61, 435, 986, 63, 589, 339, 984, 14, 2224, 8, 5781, 14, 1250, 8, 6138, 63, 589, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sborenst/openshift-ansible
inventory/openstack/hosts/nova.py
20
6730
#!/usr/bin/env python2 # pylint: skip-file # (c) 2012, Marco Vito Moscaritolo <marco@agavee.com> # # This file is part of Ansible, # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. import sys import re import os import ConfigParser from novaclient import client as nova_client try: import json except ImportError: import simplejson as json ################################################### # executed with no parameters, return the list of # all groups and hosts NOVA_CONFIG_FILES = [os.getcwd() + "/nova.ini", os.path.expanduser(os.environ.get('ANSIBLE_CONFIG', "~/nova.ini")), "/etc/ansible/nova.ini"] NOVA_DEFAULTS = { 'auth_system': None, 'region_name': None, 'service_type': 'compute', } def nova_load_config_file(): p = ConfigParser.SafeConfigParser(NOVA_DEFAULTS) for path in NOVA_CONFIG_FILES: if os.path.exists(path): p.read(path) return p return None def get_fallback(config, value, section="openstack"): """ Get value from config object and return the value or false """ try: return config.get(section, value) except ConfigParser.NoOptionError: return False def push(data, key, element): """ Assist in items to a dictionary of lists """ if (not element) or (not key): return if key in data: data[key].append(element) else: data[key] = [element] def to_safe(word): ''' Converts 'bad' characters in a string to underscores so they can be used as Ansible groups ''' return re.sub(r"[^A-Za-z0-9\-]", "_", word) def get_ips(server, access_ip=True): """ Returns a list of the server's IPs, or the preferred access IP """ private = [] public = [] address_list = [] # Iterate through each servers network(s), get addresses and get type addresses = getattr(server, 'addresses', {}) if len(addresses) > 0: for network in addresses.itervalues(): for address in network: if address.get('OS-EXT-IPS:type', False) == 'fixed': private.append(address['addr']) elif address.get('OS-EXT-IPS:type', False) == 'floating': public.append(address['addr']) if not access_ip: address_list.append(server.accessIPv4) address_list.extend(private) address_list.extend(public) return address_list access_ip = None # Append group to list if server.accessIPv4: access_ip = server.accessIPv4 if (not access_ip) and public and not (private and prefer_private): access_ip = public[0] if private and not access_ip: access_ip = private[0] return access_ip def get_metadata(server): """Returns dictionary of all host metadata""" get_ips(server, False) results = {} for key in vars(server): # Extract value value = getattr(server, key) # Generate sanitized key key = 'os_' + re.sub(r"[^A-Za-z0-9\-]", "_", key).lower() # Att value to instance result (exclude manager class) #TODO: maybe use value.__class__ or similar inside of key_name if key != 'os_manager': results[key] = value return results config = nova_load_config_file() if not config: sys.exit('Unable to find configfile in %s' % ', '.join(NOVA_CONFIG_FILES)) # Load up connections info based on config and then environment # variables username = (get_fallback(config, 'username') or os.environ.get('OS_USERNAME', None)) api_key = (get_fallback(config, 'api_key') or os.environ.get('OS_PASSWORD', None)) auth_url = (get_fallback(config, 'auth_url') or os.environ.get('OS_AUTH_URL', None)) project_id = (get_fallback(config, 'project_id') or os.environ.get('OS_TENANT_NAME', None)) region_name = (get_fallback(config, 'region_name') or os.environ.get('OS_REGION_NAME', None)) auth_system = (get_fallback(config, 'auth_system') or os.environ.get('OS_AUTH_SYSTEM', None)) # Determine what type of IP is preferred to return prefer_private = False try: prefer_private = config.getboolean('openstack', 'prefer_private') except ConfigParser.NoOptionError: pass client = nova_client.Client( version=config.get('openstack', 'version'), username=username, api_key=api_key, auth_url=auth_url, region_name=region_name, project_id=project_id, auth_system=auth_system, service_type=config.get('openstack', 'service_type'), ) # Default or added list option if (len(sys.argv) == 2 and sys.argv[1] == '--list') or len(sys.argv) == 1: groups = {'_meta': {'hostvars': {}}} # Cycle on servers for server in client.servers.list(): access_ip = get_ips(server) # Push to name group of 1 push(groups, server.name, access_ip) # Run through each metadata item and add instance to it for key, value in server.metadata.iteritems(): composed_key = to_safe('tag_{0}_{1}'.format(key, value)) push(groups, composed_key, access_ip) # Do special handling of group for backwards compat # inventory groups group = server.metadata['group'] if 'group' in server.metadata else 'undefined' push(groups, group, access_ip) # Add vars to _meta key for performance optimization in # Ansible 1.3+ groups['_meta']['hostvars'][access_ip] = get_metadata(server) # Return server list print(json.dumps(groups, sort_keys=True, indent=2)) sys.exit(0) ##################################################### # executed with a hostname as a parameter, return the # variables for that host elif len(sys.argv) == 3 and (sys.argv[1] == '--host'): results = {} ips = [] for server in client.servers.list(): if sys.argv[2] in (get_ips(server) or []): results = get_metadata(server) print(json.dumps(results, sort_keys=True, indent=2)) sys.exit(0) else: print "usage: --list ..OR.. --host <hostname>" sys.exit(1)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 3, 4287, 26, 3372, 13, 493, 199, 199, 3, 334, 67, 9, 6029, 12, 16794, 331, 812, 24308, 3930, 22707, 24308, 320, 665, 4584, 331, 32, 643, 811, 69, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 12, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 14196, 199, 504, 949, 15367, 864, 492, 1890, 465, 5913, 63, 1258, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 22529, 5680, 199, 3, 7934, 543, 949, 2633, 12, 372, 314, 769, 402, 199, 3, 1006, 4652, 436, 7057, 199, 199, 2826, 15162, 63, 5569, 63, 9472, 275, 359, 736, 14, 9458, 342, 435, 3286, 6765, 14, 2730, 401, 2151, 747, 14, 515, 14, 12131, 8, 736, 14, 2314, 14, 362, 360, 8490, 63, 5569, 297, 26810, 15, 6765, 14, 2730, 8150, 2151, 3286, 6839, 15, 4853, 15, 6765, 14, 2730, 937, 199, 199, 2826, 15162, 63, 30773, 275, 469, 272, 283, 1178, 63, 2253, 356, 488, 12, 272, 283, 4551, 63, 354, 356, 488, 12, 272, 283, 1364, 63, 466, 356, 283, 3357, 297, 199, 93, 421, 199, 318, 5913, 63, 912, 63, 888, 63, 493, 837, 272, 299, 275, 14196, 14, 11090, 15218, 8, 2826, 15162, 63, 30773, 9, 339, 367, 931, 315, 4825, 15162, 63, 5569, 63, 9472, 26, 267, 340, 747, 14, 515, 14, 2444, 8, 515, 304, 288, 299, 14, 739, 8, 515, 9, 288, 372, 299, 339, 372, 488, 421, 199, 318, 664, 63, 10538, 8, 888, 12, 574, 12, 3420, 628, 8512, 2349, 272, 408, 272, 2372, 574, 687, 1101, 909, 436, 372, 314, 574, 272, 503, 3055, 272, 408, 272, 862, 26, 267, 372, 1101, 14, 362, 8, 2792, 12, 574, 9, 272, 871, 14196, 14, 1944, 16546, 26, 267, 372, 756, 421, 199, 318, 6675, 8, 576, 12, 790, 12, 1819, 304, 272, 408, 272, 3709, 11734, 315, 2974, 370, 282, 2600, 402, 5548, 272, 408, 272, 340, 334, 1397, 1819, 9, 503, 334, 1397, 790, 304, 267, 372, 339, 340, 790, 315, 666, 26, 267, 666, 59, 498, 1055, 740, 8, 2108, 9, 272, 587, 26, 267, 666, 59, 498, 61, 275, 359, 2108, 61, 421, 199, 318, 370, 63, 3489, 8, 1027, 304, 272, 1449, 272, 19107, 283, 4087, 7, 4110, 315, 282, 1059, 370, 23998, 880, 2985, 883, 272, 506, 1202, 465, 2622, 4652, 272, 1449, 272, 372, 295, 14, 954, 8, 82, 2, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 16185, 11472, 2668, 401, 4349, 9, 421, 199, 318, 664, 63, 6142, 8, 1000, 12, 2879, 63, 711, 29, 549, 304, 272, 408, 272, 1803, 282, 769, 402, 314, 1654, 1159, 30657, 12, 503, 314, 14388, 272, 2879, 3531, 272, 408, 272, 5726, 275, 942, 272, 4575, 275, 942, 272, 2287, 63, 513, 275, 942, 272, 327, 23989, 4012, 1924, 8037, 2784, 8, 83, 395, 664, 7149, 436, 664, 730, 272, 7149, 275, 2519, 8, 1000, 12, 283, 7423, 297, 5009, 272, 340, 822, 8, 7423, 9, 690, 378, 26, 267, 367, 2784, 315, 7149, 14, 13012, 837, 288, 367, 2287, 315, 2784, 26, 355, 340, 2287, 14, 362, 360, 3100, 13, 2472, 13, 12346, 26, 466, 297, 756, 9, 508, 283, 5964, 356, 490, 5726, 14, 740, 8, 1562, 459, 2697, 1105, 355, 916, 2287, 14, 362, 360, 3100, 13, 2472, 13, 12346, 26, 466, 297, 756, 9, 508, 283, 7774, 356, 490, 4575, 14, 740, 8, 1562, 459, 2697, 1105, 339, 340, 440, 2879, 63, 711, 26, 267, 2287, 63, 513, 14, 740, 8, 1000, 14, 2732, 12179, 20, 9, 267, 2287, 63, 513, 14, 2880, 8, 4239, 9, 267, 2287, 63, 513, 14, 2880, 8, 3455, 9, 267, 372, 2287, 63, 513, 339, 2879, 63, 711, 275, 488, 272, 327, 18726, 1572, 370, 769, 272, 340, 1654, 14, 2732, 12179, 20, 26, 267, 2879, 63, 711, 275, 1654, 14, 2732, 12179, 20, 272, 340, 334, 1397, 2879, 63, 711, 9, 436, 4575, 436, 440, 334, 4239, 436, 16602, 63, 4239, 304, 267, 2879, 63, 711, 275, 4575, 59, 16, 61, 272, 340, 5726, 436, 440, 2879, 63, 711, 26, 267, 2879, 63, 711, 275, 5726, 59, 16, 61, 339, 372, 2879, 63, 711, 421, 199, 318, 664, 63, 2343, 8, 1000, 304, 272, 408, 3407, 2600, 402, 1006, 1591, 3341, 624, 272, 664, 63, 6142, 8, 1000, 12, 756, 9, 272, 2058, 275, 1052, 272, 367, 790, 315, 6802, 8, 1000, 304, 267, 327, 12892, 574, 267, 574, 275, 2519, 8, 1000, 12, 790, 9, 398, 327, 7958, 31734, 790, 267, 790, 275, 283, 736, 8650, 435, 295, 14, 954, 8, 82, 2, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 16185, 11472, 2668, 401, 790, 680, 2325, 342, 398, 327, 2854, 84, 574, 370, 1256, 754, 334, 5473, 5256, 1021, 9, 267, 327, 11768, 26, 11703, 675, 574, 855, 533, 363, 503, 8545, 6272, 402, 790, 63, 354, 267, 340, 790, 1137, 283, 736, 63, 2609, 356, 288, 2058, 59, 498, 61, 275, 574, 272, 372, 2058, 199, 199, 888, 275, 5913, 63, 912, 63, 888, 63, 493, 342, 199, 692, 440, 1101, 26, 272, 984, 14, 2224, 360, 6005, 370 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 3, 4287, 26, 3372, 13, 493, 199, 199, 3, 334, 67, 9, 6029, 12, 16794, 331, 812, 24308, 3930, 22707, 24308, 320, 665, 4584, 331, 32, 643, 811, 69, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 12, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 14196, 199, 504, 949, 15367, 864, 492, 1890, 465, 5913, 63, 1258, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 199, 199, 22529, 5680, 199, 3, 7934, 543, 949, 2633, 12, 372, 314, 769, 402, 199, 3, 1006, 4652, 436, 7057, 199, 199, 2826, 15162, 63, 5569, 63, 9472, 275, 359, 736, 14, 9458, 342, 435, 3286, 6765, 14, 2730, 401, 2151, 747, 14, 515, 14, 12131, 8, 736, 14, 2314, 14, 362, 360, 8490, 63, 5569, 297, 26810, 15, 6765, 14, 2730, 8150, 2151, 3286, 6839, 15, 4853, 15, 6765, 14, 2730, 937, 199, 199, 2826, 15162, 63, 30773, 275, 469, 272, 283, 1178, 63, 2253, 356, 488, 12, 272, 283, 4551, 63, 354, 356, 488, 12, 272, 283, 1364, 63, 466, 356, 283, 3357, 297, 199, 93, 421, 199, 318, 5913, 63, 912, 63, 888, 63, 493, 837, 272, 299, 275, 14196, 14, 11090, 15218, 8, 2826, 15162, 63, 30773, 9, 339, 367, 931, 315, 4825, 15162, 63, 5569, 63, 9472, 26, 267, 340, 747, 14, 515, 14, 2444, 8, 515, 304, 288, 299, 14, 739, 8, 515, 9, 288, 372, 299, 339, 372, 488, 421, 199, 318, 664, 63, 10538, 8, 888, 12, 574, 12, 3420, 628, 8512, 2349, 272, 408, 272, 2372, 574, 687, 1101, 909, 436, 372, 314, 574, 272, 503, 3055, 272, 408, 272, 862, 26, 267, 372, 1101, 14, 362, 8, 2792, 12, 574, 9, 272, 871, 14196, 14, 1944, 16546, 26, 267, 372, 756, 421, 199, 318, 6675, 8, 576, 12, 790, 12, 1819, 304, 272, 408, 272, 3709, 11734, 315, 2974, 370, 282, 2600, 402, 5548, 272, 408, 272, 340, 334, 1397, 1819, 9, 503, 334, 1397, 790, 304, 267, 372, 339, 340, 790, 315, 666, 26, 267, 666, 59, 498, 1055, 740, 8, 2108, 9, 272, 587, 26, 267, 666, 59, 498, 61, 275, 359, 2108, 61, 421, 199, 318, 370, 63, 3489, 8, 1027, 304, 272, 1449, 272, 19107, 283, 4087, 7, 4110, 315, 282, 1059, 370, 23998, 880, 2985, 883, 272, 506, 1202, 465, 2622, 4652, 272, 1449, 272, 372, 295, 14, 954, 8, 82, 2, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 16185, 11472, 2668, 401, 4349, 9, 421, 199, 318, 664, 63, 6142, 8, 1000, 12, 2879, 63, 711, 29, 549, 304, 272, 408, 272, 1803, 282, 769, 402, 314, 1654, 1159, 30657, 12, 503, 314, 14388, 272, 2879, 3531, 272, 408, 272, 5726, 275, 942, 272, 4575, 275, 942, 272, 2287, 63, 513, 275, 942, 272, 327, 23989, 4012, 1924, 8037, 2784, 8, 83, 395, 664, 7149, 436, 664, 730, 272, 7149, 275, 2519, 8, 1000, 12, 283, 7423, 297, 5009, 272, 340, 822, 8, 7423, 9, 690, 378, 26, 267, 367, 2784, 315, 7149, 14, 13012, 837, 288, 367, 2287, 315, 2784, 26, 355, 340, 2287, 14, 362, 360, 3100, 13, 2472, 13, 12346, 26, 466, 297, 756, 9, 508, 283, 5964, 356, 490, 5726, 14, 740, 8, 1562, 459, 2697, 1105, 355, 916, 2287, 14, 362, 360, 3100, 13, 2472, 13, 12346, 26, 466, 297, 756, 9, 508, 283, 7774, 356, 490, 4575, 14, 740, 8, 1562, 459, 2697, 1105, 339, 340, 440, 2879, 63, 711, 26, 267, 2287, 63, 513, 14, 740, 8, 1000, 14, 2732, 12179, 20, 9, 267, 2287, 63, 513, 14, 2880, 8, 4239, 9, 267, 2287, 63, 513, 14, 2880, 8, 3455, 9, 267, 372, 2287, 63, 513, 339, 2879, 63, 711, 275, 488, 272, 327, 18726, 1572, 370, 769, 272, 340, 1654, 14, 2732, 12179, 20, 26, 267, 2879, 63, 711, 275, 1654, 14, 2732, 12179, 20, 272, 340, 334, 1397, 2879, 63, 711, 9, 436, 4575, 436, 440, 334, 4239, 436, 16602, 63, 4239, 304, 267, 2879, 63, 711, 275, 4575, 59, 16, 61, 272, 340, 5726, 436, 440, 2879, 63, 711, 26, 267, 2879, 63, 711, 275, 5726, 59, 16, 61, 339, 372, 2879, 63, 711, 421, 199, 318, 664, 63, 2343, 8, 1000, 304, 272, 408, 3407, 2600, 402, 1006, 1591, 3341, 624, 272, 664, 63, 6142, 8, 1000, 12, 756, 9, 272, 2058, 275, 1052, 272, 367, 790, 315, 6802, 8, 1000, 304, 267, 327, 12892, 574, 267, 574, 275, 2519, 8, 1000, 12, 790, 9, 398, 327, 7958, 31734, 790, 267, 790, 275, 283, 736, 8650, 435, 295, 14, 954, 8, 82, 2, 4735, 33, 13, 13163, 13, 90, 16, 13, 25, 16185, 11472, 2668, 401, 790, 680, 2325, 342, 398, 327, 2854, 84, 574, 370, 1256, 754, 334, 5473, 5256, 1021, 9, 267, 327, 11768, 26, 11703, 675, 574, 855, 533, 363, 503, 8545, 6272, 402, 790, 63, 354, 267, 340, 790, 1137, 283, 736, 63, 2609, 356, 288, 2058, 59, 498, 61, 275, 574, 272, 372, 2058, 199, 199, 888, 275, 5913, 63, 912, 63, 888, 63, 493, 342, 199, 692, 440, 1101, 26, 272, 984, 14, 2224, 360, 6005, 370, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dani-esquinazi-integra/apv
pdfview/scripts/pjpp.py
111
7409
#!/usr/bin/env pypy import os, sys, logging, re import argparse import fnmatch configurations = {'lite', 'pro'} package_dirs = { 'lite': ('src/cx/hell/android/pdfview',), 'pro': ('src/cx/hell/android/pdfviewpro',) } file_replaces = { 'lite': ( 'cx.hell.android.pdfview.', '"cx.hell.android.pdfview"', 'package cx.hell.android.pdfview;', 'android:icon="@drawable/pdfviewer"', ), 'pro': ( 'cx.hell.android.pdfviewpro.', '"cx.hell.android.pdfviewpro"', 'package cx.hell.android.pdfviewpro;', 'android:icon="@drawable/apvpro_icon"', ), } def make_comment(file_type, line): """Add comment to line and return modified line, but try not to add comments to already commented out lines.""" if file_type in ('java', 'c'): return '// ' + line if not line.startswith('//') else line elif file_type in ('html', 'xml'): return '<!-- ' + line.strip() + ' -->\n' if not line.strip().startswith('<!--') else line else: raise Exception("unknown file type: %s" % file_type) def remove_comment(file_type, line): """Remove comment from line, but only if line is commented, otherwise return unchanged line.""" if file_type in ('java', 'c'): if line.startswith('// '): return line[3:] else: return line elif file_type in ('html', 'xml'): if line.strip().startswith('<!-- ') and line.strip().endswith(' -->'): return line.strip()[5:-4] + '\n' else: return line else: raise Exception("unknown file type: %s" % file_type) def handle_comments(conf, file_type, lines, filename): new_lines = [] re_cmd_starts = re.compile(r'(?:(//|<!--))\s+#ifdef\s+(?P<def>[a-zA-Z]+)') re_cmd_ends = re.compile(r'(?:(//|<!--))\s+#endif') required_defs = [] for i, line in enumerate(lines): m = re_cmd_starts.search(line) if m: required_def = m.group('def') logging.debug("line %s:%d %s matches as start of %s" % (filename, i+1, line.strip(), required_def)) required_defs.append(required_def) new_lines.append(line) continue m = re_cmd_ends.search(line) if m: logging.debug("line %s:%d %s matches as endif" % (filename, i+1, line.strip())) required_defs.pop() new_lines.append(line) continue if len(required_defs) == 0: new_lines.append(line) elif len(required_defs) == 1 and required_defs[0] == conf: new_line = remove_comment(file_type, line) new_lines.append(new_line) else: new_line = make_comment(file_type, line) new_lines.append(new_line) assert len(new_lines) == len(lines) return new_lines def find_files(dirname, name): matches = [] for root, dirnames, filenames in os.walk(dirname): for filename in fnmatch.filter(filenames, name): matches.append(os.path.join(root, filename)) return matches def fix_package_dirs(conf): for i, dirname in enumerate(package_dirs[conf]): logging.debug("trying to restore %s" % dirname) if os.path.exists(dirname): if os.path.isdir(dirname): logging.debug(" already exists") continue else: logging.error(" %s already exists, but is not dir" % dirname) continue # find other name found_dirname = None for other_conf, other_dirnames in package_dirs.items(): other_dirname = other_dirnames[i] if other_conf == conf: continue # skip this conf when looking for other conf if os.path.isdir(other_dirname): if found_dirname is None: found_dirname = other_dirname else: # source dir already found :/ raise Exception("too many possible dirs for this package: %s, %s" % (found_dirname, other_dirname)) if found_dirname is None: raise Exception("didn't find %s" % dirname) # now rename found_dirname to dirname os.rename(found_dirname, dirname) logging.debug("renamed %s to %s" % (found_dirname, dirname)) def handle_comments_in_files(conf, file_type, filenames): for filename in filenames: lines = open(filename).readlines() new_lines = handle_comments(conf, file_type, lines, filename) if lines != new_lines: logging.debug("file %s comments changed" % filename) f = open(filename, 'w') f.write(''.join(new_lines)) f.close() del f def replace_in_files(conf, filenames): #logging.debug("about replace to %s in %s" % (conf, ', '.join(filenames))) other_confs = [other_conf for other_conf in file_replaces.keys() if other_conf != conf] #logging.debug("there are %d other confs to replace from: %s" % (len(other_confs), ', '.join(other_confs))) for filename in filenames: new_lines = [] lines = open(filename).readlines() for line in lines: new_line = line for i, target_string in enumerate(file_replaces[conf]): for other_conf in other_confs: source_string = file_replaces[other_conf][i] new_line = new_line.replace(source_string, target_string) new_lines.append(new_line) if new_lines != lines: logging.debug("file %s changed, writing..." % filename) f = open(filename, 'w') f.write(''.join(new_lines)) f.close() del f else: logging.debug("file %s didn't change, no need to rewrite" % filename) def fix_java_files(conf): filenames = find_files('src', name='*.java') replace_in_files(conf, filenames) handle_comments_in_files(conf, 'java', filenames) def fix_xml_files(conf): filenames = find_files('.', name='*.xml') replace_in_files(conf, filenames) handle_comments_in_files(conf, 'xml', filenames) def fix_html_files(conf): filenames = find_files('res', name='*.html') replace_in_files(conf, filenames) handle_comments_in_files(conf, 'html', filenames) def fix_c_files(conf): filenames = find_files('jni/pdfview2', name='*.c') replace_in_files(conf, filenames) handle_comments_in_files(conf, 'c', filenames) filenames = find_files('jni/pdfview2', name='*.h') replace_in_files(conf, filenames) handle_comments_in_files(conf, 'c', filenames) def fix_resources(conf): pass def main(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') parser = argparse.ArgumentParser(description='Switch project configurations') parser.add_argument('--configuration', dest='configuration', default='lite') args = parser.parse_args() if not os.path.exists('AndroidManifest.xml'): raise Exception('android manifest not found, please run this script from main project directory') conf = args.configuration if conf not in configurations: raise Exception("invalid configuration: %s" % conf) fix_package_dirs(conf) fix_java_files(conf) fix_xml_files(conf) fix_html_files(conf) fix_c_files(conf) fix_resources(conf) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 1134, 647, 199, 199, 646, 747, 12, 984, 12, 2050, 12, 295, 199, 646, 7534, 199, 646, 15951, 4388, 199, 10057, 275, 791, 5333, 297, 283, 496, 936, 421, 199, 2491, 63, 3220, 275, 469, 272, 283, 5333, 356, 661, 2164, 15, 11859, 15, 72, 1697, 15, 6238, 15, 5607, 1345, 5529, 272, 283, 496, 356, 661, 2164, 15, 11859, 15, 72, 1697, 15, 6238, 15, 5607, 1345, 496, 9538, 199, 93, 421, 199, 493, 63, 1155, 5862, 275, 469, 272, 283, 5333, 356, 334, 267, 283, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 3130, 267, 5522, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 6949, 267, 283, 2491, 17280, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 10805, 267, 283, 6238, 26, 4677, 628, 32, 5485, 461, 15, 5607, 16645, 6949, 272, 2318, 272, 283, 496, 356, 334, 267, 283, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 496, 3130, 267, 5522, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 496, 6949, 267, 283, 2491, 17280, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 496, 10805, 267, 283, 6238, 26, 4677, 628, 32, 5485, 461, 15, 439, 86, 496, 63, 4677, 6949, 272, 2318, 199, 93, 421, 199, 318, 1852, 63, 3349, 8, 493, 63, 466, 12, 1004, 304, 272, 408, 1123, 3721, 370, 1004, 436, 372, 6042, 1004, 12, 1325, 862, 440, 370, 1050, 6786, 370, 2575, 21804, 734, 2385, 1041, 272, 340, 570, 63, 466, 315, 661, 6138, 297, 283, 67, 735, 267, 372, 18290, 283, 435, 1004, 340, 440, 1004, 14, 2460, 15079, 358, 587, 1004, 272, 916, 570, 63, 466, 315, 661, 1360, 297, 283, 1652, 735, 267, 372, 2650, 17722, 283, 435, 1004, 14, 1913, 342, 435, 283, 1553, 3072, 78, 7, 340, 440, 1004, 14, 1913, 1252, 2460, 4827, 17722, 358, 587, 1004, 272, 587, 26, 267, 746, 2186, 480, 5187, 570, 730, 26, 450, 83, 2, 450, 570, 63, 466, 9, 421, 199, 318, 2813, 63, 3349, 8, 493, 63, 466, 12, 1004, 304, 272, 408, 5587, 3721, 687, 1004, 12, 1325, 1454, 340, 1004, 365, 21804, 12, 4257, 372, 14874, 1004, 1041, 272, 340, 570, 63, 466, 315, 661, 6138, 297, 283, 67, 735, 267, 340, 1004, 14, 2460, 15079, 18927, 372, 1004, 59, 19, 2938, 267, 587, 26, 372, 1004, 272, 916, 570, 63, 466, 315, 661, 1360, 297, 283, 1652, 735, 267, 340, 1004, 14, 1913, 1252, 2460, 4827, 17722, 5320, 436, 1004, 14, 1913, 1252, 4130, 360, 10541, 735, 372, 1004, 14, 1913, 3430, 21, 6809, 20, 61, 435, 1557, 78, 7, 267, 587, 26, 372, 1004, 272, 587, 26, 267, 746, 2186, 480, 5187, 570, 730, 26, 450, 83, 2, 450, 570, 63, 466, 9, 421, 199, 318, 2429, 63, 6223, 8, 2190, 12, 570, 63, 466, 12, 2385, 12, 1788, 304, 272, 892, 63, 1278, 275, 942, 272, 295, 63, 1760, 63, 17116, 275, 295, 14, 2014, 8, 82, 20459, 8, 501, 92, 25273, 25105, 83, 11, 3, 27737, 60, 83, 11, 2229, 48, 28, 318, 9514, 65, 13, 6353, 13, 58, 2807, 5942, 272, 295, 63, 1760, 63, 3198, 275, 295, 14, 2014, 8, 82, 20459, 8, 501, 92, 25273, 25105, 83, 11, 3, 13739, 358, 272, 1415, 63, 8710, 275, 942, 272, 367, 284, 12, 1004, 315, 3874, 8, 1278, 304, 267, 333, 275, 295, 63, 1760, 63, 17116, 14, 1733, 8, 604, 9, 267, 340, 333, 26, 288, 1415, 63, 318, 275, 333, 14, 923, 360, 318, 358, 288, 2050, 14, 1757, 480, 604, 450, 83, 2689, 68, 450, 83, 4450, 465, 1343, 402, 450, 83, 2, 450, 334, 1501, 12, 284, 11, 17, 12, 1004, 14, 1913, 1062, 1415, 63, 318, 430, 288, 1415, 63, 8710, 14, 740, 8, 2427, 63, 318, 9, 288, 892, 63, 1278, 14, 740, 8, 604, 9, 288, 1980, 267, 333, 275, 295, 63, 1760, 63, 3198, 14, 1733, 8, 604, 9, 267, 340, 333, 26, 288, 2050, 14, 1757, 480, 604, 450, 83, 2689, 68, 450, 83, 4450, 465, 14454, 2, 450, 334, 1501, 12, 284, 11, 17, 12, 1004, 14, 1913, 4059, 288, 1415, 63, 8710, 14, 1935, 342, 288, 892, 63, 1278, 14, 740, 8, 604, 9, 288, 1980, 267, 340, 822, 8, 2427, 63, 8710, 9, 508, 378, 26, 288, 892, 63, 1278, 14, 740, 8, 604, 9, 267, 916, 822, 8, 2427, 63, 8710, 9, 508, 413, 436, 1415, 63, 8710, 59, 16, 61, 508, 3743, 26, 288, 892, 63, 604, 275, 2813, 63, 3349, 8, 493, 63, 466, 12, 1004, 9, 288, 892, 63, 1278, 14, 740, 8, 1222, 63, 604, 9, 267, 587, 26, 288, 892, 63, 604, 275, 1852, 63, 3349, 8, 493, 63, 466, 12, 1004, 9, 288, 892, 63, 1278, 14, 740, 8, 1222, 63, 604, 9, 272, 702, 822, 8, 1222, 63, 1278, 9, 508, 822, 8, 1278, 9, 272, 372, 892, 63, 1278, 421, 199, 318, 2342, 63, 1725, 8, 3475, 12, 536, 304, 272, 4450, 275, 942, 272, 367, 1738, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 3475, 304, 267, 367, 1788, 315, 15951, 14, 1541, 8, 10309, 12, 536, 304, 288, 4450, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 1788, 430, 272, 372, 4450, 421, 199, 318, 5325, 63, 2491, 63, 3220, 8, 2190, 304, 272, 367, 284, 12, 9017, 315, 3874, 8, 2491, 63, 3220, 59, 2190, 4682, 267, 2050, 14, 1757, 480, 893, 316, 370, 9066, 450, 83, 2, 450, 9017, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 3475, 304, 288, 340, 747, 14, 515, 14, 6027, 8, 3475, 304, 355, 2050, 14, 1757, 480, 2575, 3495, 531, 355, 1980, 288, 587, 26, 355, 2050, 14, 705, 480, 450, 83, 2575, 3495, 12, 1325, 365, 440, 2935, 2, 450, 9017, 9, 355, 1980, 267, 327, 2342, 1163, 536, 267, 1911, 63, 3475, 275, 488, 267, 367, 1163, 63, 2190, 12, 1163, 63, 694, 1247, 315, 2559, 63, 3220, 14, 1744, 837, 288, 1163, 63, 3475, 275, 1163, 63, 694, 1247, 59, 73, 61, 288, 340, 1163, 63, 2190, 508, 3743, 26, 1980, 327, 3372, 642, 3743 ]
[ 2647, 15, 1393, 15, 1813, 1134, 647, 199, 199, 646, 747, 12, 984, 12, 2050, 12, 295, 199, 646, 7534, 199, 646, 15951, 4388, 199, 10057, 275, 791, 5333, 297, 283, 496, 936, 421, 199, 2491, 63, 3220, 275, 469, 272, 283, 5333, 356, 661, 2164, 15, 11859, 15, 72, 1697, 15, 6238, 15, 5607, 1345, 5529, 272, 283, 496, 356, 661, 2164, 15, 11859, 15, 72, 1697, 15, 6238, 15, 5607, 1345, 496, 9538, 199, 93, 421, 199, 493, 63, 1155, 5862, 275, 469, 272, 283, 5333, 356, 334, 267, 283, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 3130, 267, 5522, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 6949, 267, 283, 2491, 17280, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 10805, 267, 283, 6238, 26, 4677, 628, 32, 5485, 461, 15, 5607, 16645, 6949, 272, 2318, 272, 283, 496, 356, 334, 267, 283, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 496, 3130, 267, 5522, 11859, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 496, 6949, 267, 283, 2491, 17280, 14, 72, 1697, 14, 6238, 14, 5607, 1345, 496, 10805, 267, 283, 6238, 26, 4677, 628, 32, 5485, 461, 15, 439, 86, 496, 63, 4677, 6949, 272, 2318, 199, 93, 421, 199, 318, 1852, 63, 3349, 8, 493, 63, 466, 12, 1004, 304, 272, 408, 1123, 3721, 370, 1004, 436, 372, 6042, 1004, 12, 1325, 862, 440, 370, 1050, 6786, 370, 2575, 21804, 734, 2385, 1041, 272, 340, 570, 63, 466, 315, 661, 6138, 297, 283, 67, 735, 267, 372, 18290, 283, 435, 1004, 340, 440, 1004, 14, 2460, 15079, 358, 587, 1004, 272, 916, 570, 63, 466, 315, 661, 1360, 297, 283, 1652, 735, 267, 372, 2650, 17722, 283, 435, 1004, 14, 1913, 342, 435, 283, 1553, 3072, 78, 7, 340, 440, 1004, 14, 1913, 1252, 2460, 4827, 17722, 358, 587, 1004, 272, 587, 26, 267, 746, 2186, 480, 5187, 570, 730, 26, 450, 83, 2, 450, 570, 63, 466, 9, 421, 199, 318, 2813, 63, 3349, 8, 493, 63, 466, 12, 1004, 304, 272, 408, 5587, 3721, 687, 1004, 12, 1325, 1454, 340, 1004, 365, 21804, 12, 4257, 372, 14874, 1004, 1041, 272, 340, 570, 63, 466, 315, 661, 6138, 297, 283, 67, 735, 267, 340, 1004, 14, 2460, 15079, 18927, 372, 1004, 59, 19, 2938, 267, 587, 26, 372, 1004, 272, 916, 570, 63, 466, 315, 661, 1360, 297, 283, 1652, 735, 267, 340, 1004, 14, 1913, 1252, 2460, 4827, 17722, 5320, 436, 1004, 14, 1913, 1252, 4130, 360, 10541, 735, 372, 1004, 14, 1913, 3430, 21, 6809, 20, 61, 435, 1557, 78, 7, 267, 587, 26, 372, 1004, 272, 587, 26, 267, 746, 2186, 480, 5187, 570, 730, 26, 450, 83, 2, 450, 570, 63, 466, 9, 421, 199, 318, 2429, 63, 6223, 8, 2190, 12, 570, 63, 466, 12, 2385, 12, 1788, 304, 272, 892, 63, 1278, 275, 942, 272, 295, 63, 1760, 63, 17116, 275, 295, 14, 2014, 8, 82, 20459, 8, 501, 92, 25273, 25105, 83, 11, 3, 27737, 60, 83, 11, 2229, 48, 28, 318, 9514, 65, 13, 6353, 13, 58, 2807, 5942, 272, 295, 63, 1760, 63, 3198, 275, 295, 14, 2014, 8, 82, 20459, 8, 501, 92, 25273, 25105, 83, 11, 3, 13739, 358, 272, 1415, 63, 8710, 275, 942, 272, 367, 284, 12, 1004, 315, 3874, 8, 1278, 304, 267, 333, 275, 295, 63, 1760, 63, 17116, 14, 1733, 8, 604, 9, 267, 340, 333, 26, 288, 1415, 63, 318, 275, 333, 14, 923, 360, 318, 358, 288, 2050, 14, 1757, 480, 604, 450, 83, 2689, 68, 450, 83, 4450, 465, 1343, 402, 450, 83, 2, 450, 334, 1501, 12, 284, 11, 17, 12, 1004, 14, 1913, 1062, 1415, 63, 318, 430, 288, 1415, 63, 8710, 14, 740, 8, 2427, 63, 318, 9, 288, 892, 63, 1278, 14, 740, 8, 604, 9, 288, 1980, 267, 333, 275, 295, 63, 1760, 63, 3198, 14, 1733, 8, 604, 9, 267, 340, 333, 26, 288, 2050, 14, 1757, 480, 604, 450, 83, 2689, 68, 450, 83, 4450, 465, 14454, 2, 450, 334, 1501, 12, 284, 11, 17, 12, 1004, 14, 1913, 4059, 288, 1415, 63, 8710, 14, 1935, 342, 288, 892, 63, 1278, 14, 740, 8, 604, 9, 288, 1980, 267, 340, 822, 8, 2427, 63, 8710, 9, 508, 378, 26, 288, 892, 63, 1278, 14, 740, 8, 604, 9, 267, 916, 822, 8, 2427, 63, 8710, 9, 508, 413, 436, 1415, 63, 8710, 59, 16, 61, 508, 3743, 26, 288, 892, 63, 604, 275, 2813, 63, 3349, 8, 493, 63, 466, 12, 1004, 9, 288, 892, 63, 1278, 14, 740, 8, 1222, 63, 604, 9, 267, 587, 26, 288, 892, 63, 604, 275, 1852, 63, 3349, 8, 493, 63, 466, 12, 1004, 9, 288, 892, 63, 1278, 14, 740, 8, 1222, 63, 604, 9, 272, 702, 822, 8, 1222, 63, 1278, 9, 508, 822, 8, 1278, 9, 272, 372, 892, 63, 1278, 421, 199, 318, 2342, 63, 1725, 8, 3475, 12, 536, 304, 272, 4450, 275, 942, 272, 367, 1738, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 3475, 304, 267, 367, 1788, 315, 15951, 14, 1541, 8, 10309, 12, 536, 304, 288, 4450, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1231, 12, 1788, 430, 272, 372, 4450, 421, 199, 318, 5325, 63, 2491, 63, 3220, 8, 2190, 304, 272, 367, 284, 12, 9017, 315, 3874, 8, 2491, 63, 3220, 59, 2190, 4682, 267, 2050, 14, 1757, 480, 893, 316, 370, 9066, 450, 83, 2, 450, 9017, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 3475, 304, 288, 340, 747, 14, 515, 14, 6027, 8, 3475, 304, 355, 2050, 14, 1757, 480, 2575, 3495, 531, 355, 1980, 288, 587, 26, 355, 2050, 14, 705, 480, 450, 83, 2575, 3495, 12, 1325, 365, 440, 2935, 2, 450, 9017, 9, 355, 1980, 267, 327, 2342, 1163, 536, 267, 1911, 63, 3475, 275, 488, 267, 367, 1163, 63, 2190, 12, 1163, 63, 694, 1247, 315, 2559, 63, 3220, 14, 1744, 837, 288, 1163, 63, 3475, 275, 1163, 63, 694, 1247, 59, 73, 61, 288, 340, 1163, 63, 2190, 508, 3743, 26, 1980, 327, 3372, 642, 3743, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
davidyezsetz/kuma
vendor/packages/Werkzeug/tests/test_parsing.py
6
8212
# -*- coding: utf-8 -*- from nose.tools import assert_raises from os.path import join, dirname, abspath from cStringIO import StringIO from werkzeug import Client, Request, Response from werkzeug.exceptions import RequestEntityTooLarge @Request.application def form_data_consumer(request): result_object = request.args['object'] if result_object == 'text': return Response(repr(request.form['text'])) f = request.files[result_object] return Response('\n'.join(( repr(f.filename), repr(f.name), repr(f.content_type), f.stream.read() ))) def get_contents(filename): f = file(filename, 'rb') try: return f.read() finally: f.close() def test_multipart(): """Tests multipart parsing against data collected from webbrowsers""" resources = join(dirname(__file__), 'multipart') client = Client(form_data_consumer, Response) repository = [ ('firefox3-2png1txt', '---------------------------186454651713519341951581030105', [ (u'anchor.png', 'file1', 'image/png', 'file1.png'), (u'application_edit.png', 'file2', 'image/png', 'file2.png') ], u'example text'), ('firefox3-2pnglongtext', '---------------------------14904044739787191031754711748', [ (u'accept.png', 'file1', 'image/png', 'file1.png'), (u'add.png', 'file2', 'image/png', 'file2.png') ], u'--long text\r\n--with boundary\r\n--lookalikes--'), ('opera8-2png1txt', '----------zEO9jQKmLc2Cq88c23Dx19', [ (u'arrow_branch.png', 'file1', 'image/png', 'file1.png'), (u'award_star_bronze_1.png', 'file2', 'image/png', 'file2.png') ], u'blafasel öäü'), ('webkit3-2png1txt', '----WebKitFormBoundaryjdSFhcARk8fyGNy6', [ (u'gtk-apply.png', 'file1', 'image/png', 'file1.png'), (u'gtk-no.png', 'file2', 'image/png', 'file2.png') ], u'this is another text with ümläüts'), ('ie6-2png1txt', '---------------------------7d91b03a20128', [ (u'file1.png', 'file1', 'image/x-png', 'file1.png'), (u'file2.png', 'file2', 'image/x-png', 'file2.png') ], u'ie6 sucks :-/') ] for name, boundary, files, text in repository: folder = join(resources, name) data = get_contents(join(folder, 'request.txt')) for filename, field, content_type, fsname in files: response = client.post('/?object=' + field, data=data, content_type= 'multipart/form-data; boundary="%s"' % boundary, content_length=len(data)) lines = response.data.split('\n', 3) assert lines[0] == repr(filename) assert lines[1] == repr(field) assert lines[2] == repr(content_type) assert lines[3] == get_contents(join(folder, fsname)) response = client.post('/?object=text', data=data, content_type= 'multipart/form-data; boundary="%s"' % boundary, content_length=len(data)) assert response.data == repr(text) def test_end_of_file_multipart(): """Test for multipart files ending unexpectedly""" # This test looks innocent but it was actually timeing out in # the Werkzeug 0.5 release version (#394) data = ( '--foo\r\n' 'Content-Disposition: form-data; name="test"; filename="test.txt"\r\n' 'Content-Type: text/plain\r\n\r\n' 'file contents and no end' ) data = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; boundary=foo', method='POST') assert not data.files assert not data.form def test_extra_newline_multipart(): """Test for multipart uploads with extra newlines""" # this test looks innocent but it was actually timeing out in # the Werkzeug 0.5 release version (#394) data = ( '\r\n\r\n--foo\r\n' 'Content-Disposition: form-data; name="foo"\r\n\r\n' 'a string\r\n' '--foo--' ) data = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; boundary=foo', method='POST') assert not data.files assert data.form['foo'] == 'a string' def test_nonstandard_line_endings(): """Test nonstandard line endings of multipart form data""" for nl in '\n', '\r', '\r\n': data = nl.join(( '--foo', 'Content-Disposition: form-data; name=foo', '', 'this is just bar', '--foo', 'Content-Disposition: form-data; name=bar', '', 'blafasel', '--foo--' )) req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; ' 'boundary=foo', method='POST') print req.form assert req.form['foo'] == 'this is just bar' assert req.form['bar'] == 'blafasel' def test_limiting(): """Test the limiting features""" data = 'foo=Hello+World&bar=baz' req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='application/x-www-form-urlencoded', method='POST') req.max_content_length = 4 req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='application/x-www-form-urlencoded', method='POST') req.max_content_length = 400 assert req.form['foo'] == 'Hello World' req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='application/x-www-form-urlencoded', method='POST') req.max_form_memory_size = 7 assert_raises(RequestEntityTooLarge, lambda: req.form['foo']) req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='application/x-www-form-urlencoded', method='POST') req.max_form_memory_size = 400 assert req.form['foo'] == 'Hello World' data = ('--foo\r\nContent-Disposition: form-field; name=foo\r\n\r\n' 'Hello World\r\n' '--foo\r\nContent-Disposition: form-field; name=bar\r\n\r\n' 'bar=baz\r\n--foo--') req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; boundary=foo', method='POST') req.max_content_length = 4 assert_raises(RequestEntityTooLarge, lambda: req.form['foo']) req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; boundary=foo', method='POST') req.max_content_length = 400 assert req.form['foo'] == 'Hello World' req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; boundary=foo', method='POST') req.max_form_memory_size = 7 assert_raises(RequestEntityTooLarge, lambda: req.form['foo']) req = Request.from_values(input_stream=StringIO(data), content_length=len(data), content_type='multipart/form-data; boundary=foo', method='POST') req.max_form_memory_size = 400 assert req.form['foo'] == 'Hello World'
mpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 11354, 14, 2537, 492, 702, 63, 3536, 199, 504, 747, 14, 515, 492, 4263, 12, 9017, 12, 19529, 199, 504, 15073, 492, 5228, 199, 504, 10380, 492, 6810, 12, 4784, 12, 7232, 199, 504, 10380, 14, 3924, 492, 4784, 7302, 13749, 17149, 421, 199, 32, 2017, 14, 3578, 199, 318, 1824, 63, 576, 63, 8542, 8, 1069, 304, 272, 754, 63, 785, 275, 1056, 14, 589, 459, 785, 418, 272, 340, 754, 63, 785, 508, 283, 505, 356, 267, 372, 7232, 8, 2722, 8, 1069, 14, 964, 459, 505, 5156, 272, 289, 275, 1056, 14, 1725, 59, 1099, 63, 785, 61, 272, 372, 7232, 2258, 78, 1370, 904, 1332, 267, 4700, 8, 70, 14, 1501, 395, 267, 4700, 8, 70, 14, 354, 395, 267, 4700, 8, 70, 14, 1317, 63, 466, 395, 267, 289, 14, 1745, 14, 739, 342, 272, 23183, 421, 199, 318, 664, 63, 4407, 8, 1501, 304, 272, 289, 275, 570, 8, 1501, 12, 283, 4848, 358, 272, 862, 26, 267, 372, 289, 14, 739, 342, 272, 3753, 26, 267, 289, 14, 1600, 342, 421, 199, 318, 511, 63, 10123, 837, 272, 408, 2925, 15193, 6057, 6169, 666, 13736, 687, 781, 29063, 83, 624, 272, 5944, 275, 4263, 8, 3475, 3460, 493, 10139, 283, 10123, 358, 272, 1890, 275, 6810, 8, 964, 63, 576, 63, 8542, 12, 7232, 9, 339, 7611, 275, 359, 267, 661, 15394, 19, 13, 18, 4524, 17, 2424, 297, 283, 777, 13715, 1085, 772, 1477, 2182, 1196, 8312, 1167, 1082, 11874, 11240, 709, 8507, 1717, 297, 359, 288, 334, 85, 7, 11498, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 3578, 63, 3773, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 7, 2694, 1318, 659, 267, 661, 15394, 19, 13, 18, 4524, 2809, 505, 297, 283, 777, 13715, 10721, 966, 966, 2417, 13145, 1555, 1167, 8845, 1196, 16710, 845, 18770, 297, 359, 288, 334, 85, 7, 5694, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 525, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 27529, 2809, 1318, 60, 82, 60, 78, 306, 1045, 8424, 60, 82, 60, 78, 306, 11660, 279, 3258, 397, 306, 659, 267, 661, 2262, 65, 24, 13, 18, 4524, 17, 2424, 297, 283, 9460, 90, 15471, 25, 74, 49, 43, 77, 44, 67, 18, 35, 81, 1299, 67, 1789, 36, 88, 1167, 297, 359, 288, 334, 85, 7, 7691, 63, 4694, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 65, 3079, 63, 7848, 63, 66, 2641, 806, 63, 17, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 7, 21244, 70, 482, 76, 13333, 115, 13733, 17709, 659, 267, 661, 12554, 19, 13, 18, 4524, 17, 2424, 297, 283, 375, 21666, 2821, 19831, 17694, 13107, 15907, 689, 75, 24, 1399, 15306, 89, 22, 297, 359, 288, 334, 85, 7, 12275, 13, 4998, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 12275, 13, 889, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 1133, 866, 365, 4573, 1318, 543, 13333, 121, 757, 13733, 17709, 1086, 659, 267, 661, 1873, 22, 13, 18, 4524, 17, 2424, 297, 283, 777, 13715, 23, 68, 3328, 66, 1644, 65, 1797, 1651, 297, 359, 288, 334, 85, 7, 493, 17, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 88, 13, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 493, 18, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 88, 13, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 7, 1873, 22, 18741, 5618, 22901, 6217, 272, 1622, 339, 367, 536, 12, 8424, 12, 1584, 12, 1318, 315, 7611, 26, 267, 4922, 275, 4263, 8, 4435, 12, 536, 9, 267, 666, 275, 664, 63, 4407, 8, 904, 8, 3741, 12, 283, 1069, 14, 2424, 1333, 267, 367, 1788, 12, 901, 12, 1564, 63, 466, 12, 7449, 354, 315, 1584, 26, 288, 1177, 275, 1890, 14, 1932, 2336, 31, 785, 534, 435, 901, 12, 666, 29, 576, 12, 1564, 63, 466, 29, 3521, 283, 10123, 15, 964, 13, 576, 27, 8424, 5961, 83, 4507, 450, 8424, 12, 3521, 1564, 63, 1267, 29, 552, 8, 576, 430, 288, 2385, 275, 1177, 14, 576, 14, 1294, 2258, 78, 297, 650, 9, 288, 702, 2385, 59, 16, 61, 508, 4700, 8, 1501, 9, 288, 702, 2385, 59, 17, 61, 508, 4700, 8, 698, 9, 288, 702, 2385, 59, 18, 61, 508, 4700, 8, 1317, 63, 466, 9, 288, 702, 2385, 59, 19, 61, 508, 664, 63, 4407, 8, 904, 8, 3741, 12, 7449, 354, 430, 267, 1177, 275, 1890, 14, 1932, 2336, 31, 785, 29, 505, 297, 666, 29, 576, 12, 1564, 63, 466, 29, 3044, 283, 10123, 15, 964, 13, 576, 27, 8424, 5961, 83, 4507, 450, 8424, 12, 3044, 1564, 63, 1267, 29, 552, 8, 576, 430, 267, 702, 1177, 14, 576, 508, 4700, 8, 505, 9, 421, 199, 318, 511, 63, 500, 63, 1618, 63, 493, 63, 10123, 837, 272, 408, 774, 367, 15193, 1584, 13401, 10537, 590, 624, 272, 327, 961, 511, 10734, 315, 23507, 484, 1325, 652, 1990, 5965, 900, 316, 734, 315, 272, 327, 314, 22798, 378, 14, 21, 4683, 1015, 15196, 13549, 9, 272, 666, 275, 334, 267, 2850, 1421, 60, 82, 60, 78, 7, 267, 283, 2714, 13, 15954, 26, 1824, 13, 576, 27, 536, 628, 396, 11436, 1788, 628, 396, 14, 2424, 3212, 82, 60, 78, 7, 267, 283, 2714, 13, 804, 26, 1318, 15, 6104, 60, 82, 60, 78, 60, 82, 60, 78, 7, 267, 283, 493 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 11354, 14, 2537, 492, 702, 63, 3536, 199, 504, 747, 14, 515, 492, 4263, 12, 9017, 12, 19529, 199, 504, 15073, 492, 5228, 199, 504, 10380, 492, 6810, 12, 4784, 12, 7232, 199, 504, 10380, 14, 3924, 492, 4784, 7302, 13749, 17149, 421, 199, 32, 2017, 14, 3578, 199, 318, 1824, 63, 576, 63, 8542, 8, 1069, 304, 272, 754, 63, 785, 275, 1056, 14, 589, 459, 785, 418, 272, 340, 754, 63, 785, 508, 283, 505, 356, 267, 372, 7232, 8, 2722, 8, 1069, 14, 964, 459, 505, 5156, 272, 289, 275, 1056, 14, 1725, 59, 1099, 63, 785, 61, 272, 372, 7232, 2258, 78, 1370, 904, 1332, 267, 4700, 8, 70, 14, 1501, 395, 267, 4700, 8, 70, 14, 354, 395, 267, 4700, 8, 70, 14, 1317, 63, 466, 395, 267, 289, 14, 1745, 14, 739, 342, 272, 23183, 421, 199, 318, 664, 63, 4407, 8, 1501, 304, 272, 289, 275, 570, 8, 1501, 12, 283, 4848, 358, 272, 862, 26, 267, 372, 289, 14, 739, 342, 272, 3753, 26, 267, 289, 14, 1600, 342, 421, 199, 318, 511, 63, 10123, 837, 272, 408, 2925, 15193, 6057, 6169, 666, 13736, 687, 781, 29063, 83, 624, 272, 5944, 275, 4263, 8, 3475, 3460, 493, 10139, 283, 10123, 358, 272, 1890, 275, 6810, 8, 964, 63, 576, 63, 8542, 12, 7232, 9, 339, 7611, 275, 359, 267, 661, 15394, 19, 13, 18, 4524, 17, 2424, 297, 283, 777, 13715, 1085, 772, 1477, 2182, 1196, 8312, 1167, 1082, 11874, 11240, 709, 8507, 1717, 297, 359, 288, 334, 85, 7, 11498, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 3578, 63, 3773, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 7, 2694, 1318, 659, 267, 661, 15394, 19, 13, 18, 4524, 2809, 505, 297, 283, 777, 13715, 10721, 966, 966, 2417, 13145, 1555, 1167, 8845, 1196, 16710, 845, 18770, 297, 359, 288, 334, 85, 7, 5694, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 525, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 27529, 2809, 1318, 60, 82, 60, 78, 306, 1045, 8424, 60, 82, 60, 78, 306, 11660, 279, 3258, 397, 306, 659, 267, 661, 2262, 65, 24, 13, 18, 4524, 17, 2424, 297, 283, 9460, 90, 15471, 25, 74, 49, 43, 77, 44, 67, 18, 35, 81, 1299, 67, 1789, 36, 88, 1167, 297, 359, 288, 334, 85, 7, 7691, 63, 4694, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 65, 3079, 63, 7848, 63, 66, 2641, 806, 63, 17, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 7, 21244, 70, 482, 76, 13333, 115, 13733, 17709, 659, 267, 661, 12554, 19, 13, 18, 4524, 17, 2424, 297, 283, 375, 21666, 2821, 19831, 17694, 13107, 15907, 689, 75, 24, 1399, 15306, 89, 22, 297, 359, 288, 334, 85, 7, 12275, 13, 4998, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 12275, 13, 889, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 1133, 866, 365, 4573, 1318, 543, 13333, 121, 757, 13733, 17709, 1086, 659, 267, 661, 1873, 22, 13, 18, 4524, 17, 2424, 297, 283, 777, 13715, 23, 68, 3328, 66, 1644, 65, 1797, 1651, 297, 359, 288, 334, 85, 7, 493, 17, 14, 4524, 297, 283, 493, 17, 297, 283, 1569, 15, 88, 13, 4524, 297, 283, 493, 17, 14, 4524, 659, 288, 334, 85, 7, 493, 18, 14, 4524, 297, 283, 493, 18, 297, 283, 1569, 15, 88, 13, 4524, 297, 283, 493, 18, 14, 4524, 358, 267, 2156, 399, 7, 1873, 22, 18741, 5618, 22901, 6217, 272, 1622, 339, 367, 536, 12, 8424, 12, 1584, 12, 1318, 315, 7611, 26, 267, 4922, 275, 4263, 8, 4435, 12, 536, 9, 267, 666, 275, 664, 63, 4407, 8, 904, 8, 3741, 12, 283, 1069, 14, 2424, 1333, 267, 367, 1788, 12, 901, 12, 1564, 63, 466, 12, 7449, 354, 315, 1584, 26, 288, 1177, 275, 1890, 14, 1932, 2336, 31, 785, 534, 435, 901, 12, 666, 29, 576, 12, 1564, 63, 466, 29, 3521, 283, 10123, 15, 964, 13, 576, 27, 8424, 5961, 83, 4507, 450, 8424, 12, 3521, 1564, 63, 1267, 29, 552, 8, 576, 430, 288, 2385, 275, 1177, 14, 576, 14, 1294, 2258, 78, 297, 650, 9, 288, 702, 2385, 59, 16, 61, 508, 4700, 8, 1501, 9, 288, 702, 2385, 59, 17, 61, 508, 4700, 8, 698, 9, 288, 702, 2385, 59, 18, 61, 508, 4700, 8, 1317, 63, 466, 9, 288, 702, 2385, 59, 19, 61, 508, 664, 63, 4407, 8, 904, 8, 3741, 12, 7449, 354, 430, 267, 1177, 275, 1890, 14, 1932, 2336, 31, 785, 29, 505, 297, 666, 29, 576, 12, 1564, 63, 466, 29, 3044, 283, 10123, 15, 964, 13, 576, 27, 8424, 5961, 83, 4507, 450, 8424, 12, 3044, 1564, 63, 1267, 29, 552, 8, 576, 430, 267, 702, 1177, 14, 576, 508, 4700, 8, 505, 9, 421, 199, 318, 511, 63, 500, 63, 1618, 63, 493, 63, 10123, 837, 272, 408, 774, 367, 15193, 1584, 13401, 10537, 590, 624, 272, 327, 961, 511, 10734, 315, 23507, 484, 1325, 652, 1990, 5965, 900, 316, 734, 315, 272, 327, 314, 22798, 378, 14, 21, 4683, 1015, 15196, 13549, 9, 272, 666, 275, 334, 267, 2850, 1421, 60, 82, 60, 78, 7, 267, 283, 2714, 13, 15954, 26, 1824, 13, 576, 27, 536, 628, 396, 11436, 1788, 628, 396, 14, 2424, 3212, 82, 60, 78, 7, 267, 283, 2714, 13, 804, 26, 1318, 15, 6104, 60, 82, 60, 78, 60, 82, 60, 78, 7, 267, 283, 493, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
campbe13/openhatch
vendor/packages/twisted/twisted/conch/client/options.py
17
4244
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. # from twisted.conch.ssh.transport import SSHClientTransport, SSHCiphers from twisted.python import usage import sys class ConchOptions(usage.Options): optParameters = [['user', 'l', None, 'Log in using this user name.'], ['identity', 'i', None], ['ciphers', 'c', None], ['macs', 'm', None], ['port', 'p', None, 'Connect to this port. Server must be on the same port.'], ['option', 'o', None, 'Ignored OpenSSH options'], ['host-key-algorithms', '', None], ['known-hosts', '', None, 'File to check for host keys'], ['user-authentications', '', None, 'Types of user authentications to use.'], ['logfile', '', None, 'File to log to, or - for stdout'], ] optFlags = [['version', 'V', 'Display version number only.'], ['compress', 'C', 'Enable compression.'], ['log', 'v', 'Enable logging (defaults to stderr)'], ['nox11', 'x', 'Disable X11 connection forwarding (default)'], ['agent', 'A', 'Enable authentication agent forwarding'], ['noagent', 'a', 'Disable authentication agent forwarding (default)'], ['reconnect', 'r', 'Reconnect to the server if the connection is lost.'], ] zsh_altArgDescr = {"connection-usage":"Connection types to use"} #zsh_multiUse = ["foo", "bar"] zsh_mutuallyExclusive = [("agent", "noagent")] zsh_actions = {"user":"_users", "ciphers":"_values -s , 'ciphers to choose from' %s" % " ".join(SSHCiphers.cipherMap.keys()), "macs":"_values -s , 'macs to choose from' %s" % " ".join(SSHCiphers.macMap.keys()), "host-key-algorithms":"_values -s , 'host key algorithms to choose from' %s" % " ".join(SSHClientTransport.supportedPublicKeys), #"user-authentications":"_values -s , 'user authentication types to choose from' %s" % # " ".join(???), } #zsh_actionDescr = {"logfile":"log file name", "random":"random seed"} # user, host, or user@host completion similar to zsh's ssh completion zsh_extras = ['1:host | user@host:{_ssh;if compset -P "*@"; then _wanted hosts expl "remote host name" _ssh_hosts && ret=0 elif compset -S "@*"; then _wanted users expl "login name" _ssh_users -S "" && ret=0 else if (( $+opt_args[-l] )); then tmp=() else tmp=( "users:login name:_ssh_users -qS@" ) fi; _alternative "hosts:remote host name:_ssh_hosts" "$tmp[@]" && ret=0 fi}'] def __init__(self, *args, **kw): usage.Options.__init__(self, *args, **kw) self.identitys = [] self.conns = None def opt_identity(self, i): """Identity for public-key authentication""" self.identitys.append(i) def opt_ciphers(self, ciphers): "Select encryption algorithms" ciphers = ciphers.split(',') for cipher in ciphers: if not SSHCiphers.cipherMap.has_key(cipher): sys.exit("Unknown cipher type '%s'" % cipher) self['ciphers'] = ciphers def opt_macs(self, macs): "Specify MAC algorithms" macs = macs.split(',') for mac in macs: if not SSHCiphers.macMap.has_key(mac): sys.exit("Unknown mac type '%s'" % mac) self['macs'] = macs def opt_host_key_algorithms(self, hkas): "Select host key algorithms" hkas = hkas.split(',') for hka in hkas: if hka not in SSHClientTransport.supportedPublicKeys: sys.exit("Unknown host key type '%s'" % hka) self['host-key-algorithms'] = hkas def opt_user_authentications(self, uas): "Choose how to authenticate to the remote server" self['user-authentications'] = uas.split(',') # def opt_compress(self): # "Enable compression" # self.enableCompression = 1 # SSHClientTransport.supportedCompressions[0:1] = ['zlib']
agpl-3.0
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 3, 199, 504, 7390, 14, 388, 335, 14, 5510, 14, 5545, 492, 12027, 3041, 7836, 12, 12027, 35, 27198, 199, 504, 7390, 14, 1548, 492, 4503, 199, 199, 646, 984, 199, 199, 533, 1448, 335, 4558, 8, 3807, 14, 4558, 304, 339, 2450, 5976, 275, 11194, 751, 297, 283, 76, 297, 488, 12, 283, 2445, 315, 1808, 642, 922, 536, 14, 995, 2151, 788, 5582, 297, 283, 73, 297, 488, 467, 2151, 788, 27426, 297, 283, 67, 297, 488, 467, 2151, 788, 19309, 297, 283, 77, 297, 488, 467, 2151, 788, 719, 297, 283, 80, 297, 488, 12, 283, 8631, 370, 642, 1844, 14, 221, 7146, 1471, 506, 641, 314, 2011, 1844, 14, 995, 2151, 788, 1422, 297, 283, 79, 297, 488, 12, 283, 19399, 2908, 3232, 13716, 1511, 995, 2151, 788, 1102, 13, 498, 13, 24365, 297, 3260, 488, 467, 2151, 788, 3159, 13, 5146, 297, 3260, 488, 12, 283, 1173, 370, 1104, 367, 1591, 2883, 995, 2151, 788, 751, 13, 1178, 2815, 1298, 297, 3260, 488, 12, 283, 4100, 402, 922, 28532, 1298, 370, 675, 14, 995, 2151, 788, 12804, 297, 3260, 488, 12, 283, 1173, 370, 943, 370, 12, 503, 446, 367, 3839, 995, 673, 1622, 339, 2450, 6381, 275, 11194, 1023, 297, 283, 54, 297, 283, 7687, 1015, 1329, 1454, 14, 995, 355, 788, 6447, 297, 283, 35, 297, 283, 6476, 10291, 14, 995, 355, 788, 793, 297, 283, 86, 297, 283, 6476, 2050, 334, 4322, 370, 4635, 9, 995, 355, 788, 889, 88, 845, 297, 283, 88, 297, 283, 13707, 1323, 845, 1950, 24119, 334, 885, 9, 995, 355, 788, 4054, 297, 283, 33, 297, 283, 6476, 6299, 6631, 24119, 995, 355, 788, 889, 4054, 297, 283, 65, 297, 283, 13707, 6299, 6631, 24119, 334, 885, 9, 995, 355, 788, 29464, 297, 283, 82, 297, 283, 497, 2242, 370, 314, 1654, 340, 314, 1950, 365, 14669, 14, 995, 2049, 1622, 272, 1315, 609, 63, 4478, 6373, 28782, 275, 2420, 2105, 13, 3807, 5122, 3225, 2943, 370, 675, 3570, 272, 327, 90, 609, 63, 3029, 6119, 275, 2097, 1421, 401, 298, 1700, 937, 272, 1315, 609, 63, 25024, 26281, 275, 10003, 4054, 401, 298, 889, 4054, 11323, 272, 1315, 609, 63, 3723, 275, 2420, 751, 5122, 63, 3707, 401, 673, 298, 27426, 5122, 63, 1459, 446, 83, 2360, 283, 27426, 370, 11496, 687, 7, 450, 83, 2, 450, 2432, 298, 3680, 904, 8, 13716, 35, 27198, 14, 9231, 2956, 14, 1612, 4000, 673, 298, 19309, 5122, 63, 1459, 446, 83, 2360, 283, 19309, 370, 11496, 687, 7, 450, 83, 2, 450, 2432, 298, 3680, 904, 8, 13716, 35, 27198, 14, 3088, 2956, 14, 1612, 4000, 673, 298, 1102, 13, 498, 13, 24365, 5122, 63, 1459, 446, 83, 2360, 283, 1102, 790, 18036, 370, 11496, 687, 7, 450, 83, 2, 450, 2432, 298, 3680, 904, 8, 13716, 3041, 7836, 14, 4946, 9885, 6340, 395, 673, 20383, 751, 13, 1178, 2815, 1298, 5122, 63, 1459, 446, 83, 2360, 283, 751, 6299, 2943, 370, 11496, 687, 7, 450, 83, 2, 450, 673, 327, 259, 298, 3680, 904, 2229, 10674, 395, 673, 789, 272, 327, 90, 609, 63, 1287, 28782, 275, 2420, 12804, 5122, 793, 570, 536, 401, 298, 2355, 5122, 2355, 6347, 3570, 272, 327, 922, 12, 1591, 12, 503, 922, 32, 1102, 13659, 8545, 370, 1315, 609, 1159, 8635, 13659, 272, 1315, 609, 63, 9975, 275, 788, 17, 26, 1102, 1204, 922, 32, 1102, 14534, 63, 5510, 27, 692, 1013, 409, 446, 48, 8969, 32, 11436, 2066, 485, 19361, 7057, 29278, 298, 3846, 1591, 536, 2, 485, 5510, 63, 5146, 10883, 2203, 29, 16, 916, 1013, 409, 446, 51, 9244, 10, 11436, 2066, 485, 19361, 4390, 29278, 298, 2886, 536, 2, 485, 5510, 63, 3707, 446, 51, 3087, 10883, 2203, 29, 16, 587, 340, 3666, 2672, 11, 2992, 63, 589, 1988, 76, 61, 5082, 27, 2066, 3529, 29, 342, 587, 3529, 2687, 298, 3707, 26, 2886, 536, 22003, 5510, 63, 3707, 446, 81, 51, 32, 2, 776, 5883, 27, 485, 19389, 298, 5146, 26, 3846, 1591, 536, 22003, 5510, 63, 5146, 2, 7880, 2791, 14251, 8480, 10883, 2203, 29, 16, 5883, 93, 418, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 4503, 14, 4558, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 291, 14, 5582, 83, 275, 942, 4960, 291, 14, 30039, 275, 488, 339, 347, 2450, 63, 5582, 8, 277, 12, 284, 304, 267, 408, 10193, 367, 4575, 13, 498, 6299, 624, 267, 291, 14, 5582, 83, 14, 740, 8, 73, 9, 339, 347, 2450, 63, 27426, 8, 277, 12, 30377, 304, 267, 298, 5446, 14396, 18036, 2, 267, 30377, 275, 30377, 14, 1294, 11917, 267, 367, 10830, 315, 30377, 26, 288, 340, 440, 12027, 35, 27198, 14, 9231, 2956, 14, 1989, 63, 498, 8, 9231, 304, 355, 984, 14, 2224, 480, 5912, 10830, 730, 1543, 83, 4065, 450, 10830, 9, 267, 291, 459, 27426, 418, 275, 30377, 2378, 347, 2450, 63, 19309, 8, 277, 12, 610, 1259, 304, 267, 298, 17768, 13347, 18036, 2, 267, 610, 1259, 275, 610, 1259, 14, 1294, 11917, 267, 367, 4497, 315, 610, 1259, 26, 288, 340, 440, 12027, 35, 27198, 14, 3088, 2956, 14, 1989, 63, 498, 8, 3088, 304, 355, 984, 14, 2224, 480, 5912, 4497, 730, 1543, 83, 4065, 450, 4497, 9, 267, 291, 459, 19309, 418, 275, 610, 1259, 339, 347, 2450, 63, 1102, 63, 498, 63, 24365, 8, 277, 12, 394, 75, 305, 304, 267, 298, 5446, 1591, 790, 18036, 2, 267, 394, 75, 305, 275, 394, 75, 305, 14, 1294, 11917, 267, 367, 394, 7351, 315, 394, 75, 305, 26, 288, 340, 394, 7351, 440, 315, 12027, 3041, 7836, 14, 4946, 9885, 6340, 26, 355, 984, 14, 2224, 480, 5912, 1591, 790, 730, 1543, 83, 4065, 450, 394, 7351, 9, 267, 291, 459, 1102, 13, 498, 13, 24365, 418, 275, 394, 75, 305, 339, 347, 2450, 63, 751, 63, 1178, 2815, 1298, 8, 277, 12, 399, 305, 304, 267, 298, 23932, 4212, 370, 12895, 370, 314, 3982, 1654, 2, 267, 291 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 3, 199, 504, 7390, 14, 388, 335, 14, 5510, 14, 5545, 492, 12027, 3041, 7836, 12, 12027, 35, 27198, 199, 504, 7390, 14, 1548, 492, 4503, 199, 199, 646, 984, 199, 199, 533, 1448, 335, 4558, 8, 3807, 14, 4558, 304, 339, 2450, 5976, 275, 11194, 751, 297, 283, 76, 297, 488, 12, 283, 2445, 315, 1808, 642, 922, 536, 14, 995, 2151, 788, 5582, 297, 283, 73, 297, 488, 467, 2151, 788, 27426, 297, 283, 67, 297, 488, 467, 2151, 788, 19309, 297, 283, 77, 297, 488, 467, 2151, 788, 719, 297, 283, 80, 297, 488, 12, 283, 8631, 370, 642, 1844, 14, 221, 7146, 1471, 506, 641, 314, 2011, 1844, 14, 995, 2151, 788, 1422, 297, 283, 79, 297, 488, 12, 283, 19399, 2908, 3232, 13716, 1511, 995, 2151, 788, 1102, 13, 498, 13, 24365, 297, 3260, 488, 467, 2151, 788, 3159, 13, 5146, 297, 3260, 488, 12, 283, 1173, 370, 1104, 367, 1591, 2883, 995, 2151, 788, 751, 13, 1178, 2815, 1298, 297, 3260, 488, 12, 283, 4100, 402, 922, 28532, 1298, 370, 675, 14, 995, 2151, 788, 12804, 297, 3260, 488, 12, 283, 1173, 370, 943, 370, 12, 503, 446, 367, 3839, 995, 673, 1622, 339, 2450, 6381, 275, 11194, 1023, 297, 283, 54, 297, 283, 7687, 1015, 1329, 1454, 14, 995, 355, 788, 6447, 297, 283, 35, 297, 283, 6476, 10291, 14, 995, 355, 788, 793, 297, 283, 86, 297, 283, 6476, 2050, 334, 4322, 370, 4635, 9, 995, 355, 788, 889, 88, 845, 297, 283, 88, 297, 283, 13707, 1323, 845, 1950, 24119, 334, 885, 9, 995, 355, 788, 4054, 297, 283, 33, 297, 283, 6476, 6299, 6631, 24119, 995, 355, 788, 889, 4054, 297, 283, 65, 297, 283, 13707, 6299, 6631, 24119, 334, 885, 9, 995, 355, 788, 29464, 297, 283, 82, 297, 283, 497, 2242, 370, 314, 1654, 340, 314, 1950, 365, 14669, 14, 995, 2049, 1622, 272, 1315, 609, 63, 4478, 6373, 28782, 275, 2420, 2105, 13, 3807, 5122, 3225, 2943, 370, 675, 3570, 272, 327, 90, 609, 63, 3029, 6119, 275, 2097, 1421, 401, 298, 1700, 937, 272, 1315, 609, 63, 25024, 26281, 275, 10003, 4054, 401, 298, 889, 4054, 11323, 272, 1315, 609, 63, 3723, 275, 2420, 751, 5122, 63, 3707, 401, 673, 298, 27426, 5122, 63, 1459, 446, 83, 2360, 283, 27426, 370, 11496, 687, 7, 450, 83, 2, 450, 2432, 298, 3680, 904, 8, 13716, 35, 27198, 14, 9231, 2956, 14, 1612, 4000, 673, 298, 19309, 5122, 63, 1459, 446, 83, 2360, 283, 19309, 370, 11496, 687, 7, 450, 83, 2, 450, 2432, 298, 3680, 904, 8, 13716, 35, 27198, 14, 3088, 2956, 14, 1612, 4000, 673, 298, 1102, 13, 498, 13, 24365, 5122, 63, 1459, 446, 83, 2360, 283, 1102, 790, 18036, 370, 11496, 687, 7, 450, 83, 2, 450, 2432, 298, 3680, 904, 8, 13716, 3041, 7836, 14, 4946, 9885, 6340, 395, 673, 20383, 751, 13, 1178, 2815, 1298, 5122, 63, 1459, 446, 83, 2360, 283, 751, 6299, 2943, 370, 11496, 687, 7, 450, 83, 2, 450, 673, 327, 259, 298, 3680, 904, 2229, 10674, 395, 673, 789, 272, 327, 90, 609, 63, 1287, 28782, 275, 2420, 12804, 5122, 793, 570, 536, 401, 298, 2355, 5122, 2355, 6347, 3570, 272, 327, 922, 12, 1591, 12, 503, 922, 32, 1102, 13659, 8545, 370, 1315, 609, 1159, 8635, 13659, 272, 1315, 609, 63, 9975, 275, 788, 17, 26, 1102, 1204, 922, 32, 1102, 14534, 63, 5510, 27, 692, 1013, 409, 446, 48, 8969, 32, 11436, 2066, 485, 19361, 7057, 29278, 298, 3846, 1591, 536, 2, 485, 5510, 63, 5146, 10883, 2203, 29, 16, 916, 1013, 409, 446, 51, 9244, 10, 11436, 2066, 485, 19361, 4390, 29278, 298, 2886, 536, 2, 485, 5510, 63, 3707, 446, 51, 3087, 10883, 2203, 29, 16, 587, 340, 3666, 2672, 11, 2992, 63, 589, 1988, 76, 61, 5082, 27, 2066, 3529, 29, 342, 587, 3529, 2687, 298, 3707, 26, 2886, 536, 22003, 5510, 63, 3707, 446, 81, 51, 32, 2, 776, 5883, 27, 485, 19389, 298, 5146, 26, 3846, 1591, 536, 22003, 5510, 63, 5146, 2, 7880, 2791, 14251, 8480, 10883, 2203, 29, 16, 5883, 93, 418, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 4503, 14, 4558, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 291, 14, 5582, 83, 275, 942, 4960, 291, 14, 30039, 275, 488, 339, 347, 2450, 63, 5582, 8, 277, 12, 284, 304, 267, 408, 10193, 367, 4575, 13, 498, 6299, 624, 267, 291, 14, 5582, 83, 14, 740, 8, 73, 9, 339, 347, 2450, 63, 27426, 8, 277, 12, 30377, 304, 267, 298, 5446, 14396, 18036, 2, 267, 30377, 275, 30377, 14, 1294, 11917, 267, 367, 10830, 315, 30377, 26, 288, 340, 440, 12027, 35, 27198, 14, 9231, 2956, 14, 1989, 63, 498, 8, 9231, 304, 355, 984, 14, 2224, 480, 5912, 10830, 730, 1543, 83, 4065, 450, 10830, 9, 267, 291, 459, 27426, 418, 275, 30377, 2378, 347, 2450, 63, 19309, 8, 277, 12, 610, 1259, 304, 267, 298, 17768, 13347, 18036, 2, 267, 610, 1259, 275, 610, 1259, 14, 1294, 11917, 267, 367, 4497, 315, 610, 1259, 26, 288, 340, 440, 12027, 35, 27198, 14, 3088, 2956, 14, 1989, 63, 498, 8, 3088, 304, 355, 984, 14, 2224, 480, 5912, 4497, 730, 1543, 83, 4065, 450, 4497, 9, 267, 291, 459, 19309, 418, 275, 610, 1259, 339, 347, 2450, 63, 1102, 63, 498, 63, 24365, 8, 277, 12, 394, 75, 305, 304, 267, 298, 5446, 1591, 790, 18036, 2, 267, 394, 75, 305, 275, 394, 75, 305, 14, 1294, 11917, 267, 367, 394, 7351, 315, 394, 75, 305, 26, 288, 340, 394, 7351, 440, 315, 12027, 3041, 7836, 14, 4946, 9885, 6340, 26, 355, 984, 14, 2224, 480, 5912, 1591, 790, 730, 1543, 83, 4065, 450, 394, 7351, 9, 267, 291, 459, 1102, 13, 498, 13, 24365, 418, 275, 394, 75, 305, 339, 347, 2450, 63, 751, 63, 1178, 2815, 1298, 8, 277, 12, 399, 305, 304, 267, 298, 23932, 4212, 370, 12895, 370, 314, 3982, 1654, 2, 267, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
h4wldev/Frest
app/routes/api/v1/users/user.py
1
6676
# # -*- coding: utf-8 -*- import re import datetime from flask import request from flask_api import status from flask_restful import Resource from sqlalchemy.exc import IntegrityError from werkzeug.security import generate_password_hash from app import db, token_auth from app.models.user_model import UserModel, get_user from app.models.user_token_model import token_is_auth, token_load_with_auth, token_expire_all, token_delete_all from app.modules import frest from app.modules.frest.api.error import get_exists_error from app.modules.frest.validate import user as userValidate from app.modules.frest.serialize.user import serialize_user _URL = '/users/<prefix>' class User(Resource): """ @api {get} /users/:prefix Get particular user's info @apiName User Info @apiGroup Users @apiHeader {String} Authorization Access token. @apiHeaderExample {json} Header-Example: { "Authorization": "304924" } @apiParam {String} prefix user's prefix @apiSuccess (200) {String} data Users data. @apiError (401) UnAuthorized You don't have permission. @apiError (400) ValueError Prefix can only be me or number """ @frest.API @token_auth.login_required def get(self, prefix): try: if prefix == 'me': user_id = token_load_with_auth(request.headers['Authorization'])['user_id'] else: user_id = int(prefix) if token_is_auth(request.headers['Authorization'], user_id): user = get_user(user_id) return serialize_user(user), status.HTTP_200_OK else: return "You don't have permission.", status.HTTP_401_UNAUTHORIZED except ValueError: return "Prefix can only be me or a number.", status.HTTP_400_BAD_REQUEST """ @api {put} /users/:prefix Update user info @apiName Update user info @apiGroup Users @apiPermission Admin @apiHeader {String} Authorization Access token. @apiHeaderExample {json} Header-Example: { "Authorization": "304924" } @apiParam {String} prefix user's prefix @apiSuccess (200) None @apiError (400) BadRequest Invalid input - Prefix can only be me or a number. @apiError (401) UnAuthorized You don't have permission - Should be admin. @apiError (404) NotFound User not found. """ @frest.API @token_auth.login_required def put(self, prefix): try: if prefix == 'me': user_id = token_load_with_auth(request.headers['Authorization'])['user_id'] else: user_id = int(prefix) user_query = UserModel.query \ .filter(UserModel.id == user_id) if token_is_auth(request.headers['Authorization'], user_id): user_permission = token_load_with_auth(request.headers['Authorization'])['permission'] if user_permission != 'ADMIN' and request.form.get('permission') is not None: return "You don't have permission.", status.HTTP_401_UNAUTHORIZED form = userValidate.modificationForm(request.form) if form.validate(): if user_query.count(): user = user_query.first() try: for key, value in request.form.items(): if value is not None and value != '': if key == 'password': value = generate_password_hash(value) token_expire_all(user.id) setattr(user, key, value) user.updated_at = datetime.datetime.now() db.session.commit() except IntegrityError as e: field, value = get_exists_error(e) _return = { 'message': "'" + value + "' is already exists.", 'field': { 'label': getattr(form, field).label.text, 'name': field } } return _return, status.HTTP_400_BAD_REQUEST return None, status.HTTP_200_OK else: return "The user does not exist.", status.HTTP_404_NOT_FOUND for field, errors in form.errors.items(): for error in errors: _return = { 'message': error, 'field': getattr(form, field).label.text } return _return, status.HTTP_400_BAD_REQUEST else: return "You don't have permission.", status.HTTP_401_UNAUTHORIZED except ValueError: return "Prefix can only be me or a number.", status.HTTP_400_BAD_REQUEST """ @api {delete} /users/:prefix Delete user @apiName User Delete @apiGroup Users @apiHeader {String} Authorization Access token. @apiHeaderExample {json} Header-Example: { "Authorization": "304924" } @apiParam {String} prefix user's prefix @apiSuccess (200) None @apiError (404) NotFound User not found. @apiError (401) UnAuthorized You don't have permission. @apiError (400) ValueError Prefix can only be me or number """ @frest.API @token_auth.login_required def delete(self, prefix): try: if prefix == 'me': user_id = token_load_with_auth(request.headers['Authorization'])['user_id'] else: user_id = int(prefix) user_query = UserModel.query \ .filter(UserModel.id == user_id) if token_is_auth(request.headers['Authorization'], user_id): if user_query.count(): token_delete_all(user_id) user = user_query.first() db.session.delete(user) db.session.commit() return None, status.HTTP_200_OK else: return "The user does not exist.", status.HTTP_404_NOT_FOUND else: return "You don't have permission.", status.HTTP_401_UNAUTHORIZED except ValueError: return "Prefix can only be me or a number.", status.HTTP_400_BAD_REQUEST
mit
[ 3, 327, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 295, 199, 646, 2197, 199, 199, 504, 7209, 492, 1056, 199, 504, 7209, 63, 1246, 492, 2004, 199, 504, 7209, 63, 3911, 1893, 492, 7337, 199, 504, 8335, 14, 2804, 492, 26864, 199, 504, 10380, 14, 4416, 492, 3550, 63, 2060, 63, 2227, 199, 199, 504, 1145, 492, 1592, 12, 1526, 63, 1178, 199, 504, 1145, 14, 992, 14, 751, 63, 1238, 492, 2876, 1685, 12, 664, 63, 751, 199, 504, 1145, 14, 992, 14, 751, 63, 1418, 63, 1238, 492, 1526, 63, 374, 63, 1178, 12, 1526, 63, 912, 63, 1045, 63, 1178, 12, 1526, 63, 14691, 63, 452, 12, 1526, 63, 1807, 63, 452, 199, 504, 1145, 14, 3112, 492, 289, 3911, 199, 504, 1145, 14, 3112, 14, 70, 3911, 14, 1246, 14, 705, 492, 664, 63, 2444, 63, 705, 199, 504, 1145, 14, 3112, 14, 70, 3911, 14, 3502, 492, 922, 465, 922, 12584, 199, 504, 1145, 14, 3112, 14, 70, 3911, 14, 3549, 14, 751, 492, 8437, 63, 751, 199, 199, 63, 2632, 275, 1994, 3707, 8316, 1861, 3524, 421, 199, 533, 2876, 8, 4031, 304, 272, 408, 272, 768, 1246, 469, 362, 93, 1182, 3707, 22075, 1861, 2372, 6770, 922, 1159, 2256, 272, 768, 1246, 985, 2876, 10332, 272, 768, 1246, 2448, 20123, 339, 768, 1246, 2567, 469, 1558, 93, 21527, 11003, 1526, 14, 272, 768, 1246, 2567, 9846, 469, 1001, 93, 10240, 13, 9846, 26, 267, 469, 288, 298, 11626, 582, 298, 8533, 30666, 2, 267, 789, 339, 768, 1246, 4098, 469, 1558, 93, 2403, 922, 1159, 2403, 339, 768, 1246, 8300, 334, 1840, 9, 469, 1558, 93, 666, 20123, 666, 14, 272, 768, 1246, 547, 334, 8854, 9, 1910, 29284, 2047, 2793, 1133, 1172, 4983, 14, 272, 768, 1246, 547, 334, 5303, 9, 1722, 25110, 883, 1454, 506, 562, 503, 1329, 272, 408, 339, 768, 70, 3911, 14, 3735, 272, 768, 1418, 63, 1178, 14, 2886, 63, 2427, 272, 347, 664, 8, 277, 12, 2403, 304, 267, 862, 26, 288, 340, 2403, 508, 283, 278, 356, 355, 922, 63, 344, 275, 1526, 63, 912, 63, 1045, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 1105, 459, 751, 63, 344, 418, 288, 587, 26, 355, 922, 63, 344, 275, 1109, 8, 1861, 9, 953, 340, 1526, 63, 374, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 995, 922, 63, 344, 304, 355, 922, 275, 664, 63, 751, 8, 751, 63, 344, 9, 2234, 372, 8437, 63, 751, 8, 751, 395, 2004, 14, 2856, 63, 1840, 63, 3593, 288, 587, 26, 355, 372, 298, 5556, 2793, 1133, 1172, 4983, 4765, 2004, 14, 2856, 63, 8854, 63, 1734, 25303, 1149, 267, 871, 1722, 26, 288, 372, 298, 4793, 883, 1454, 506, 562, 503, 282, 1329, 4765, 2004, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 339, 408, 272, 768, 1246, 469, 524, 93, 1182, 3707, 22075, 1861, 6162, 922, 2256, 272, 768, 1246, 985, 6162, 922, 2256, 272, 768, 1246, 2448, 20123, 272, 768, 1246, 7980, 9516, 339, 768, 1246, 2567, 469, 1558, 93, 21527, 11003, 1526, 14, 272, 768, 1246, 2567, 9846, 469, 1001, 93, 10240, 13, 9846, 26, 267, 469, 288, 298, 11626, 582, 298, 8533, 30666, 2, 267, 789, 339, 768, 1246, 4098, 469, 1558, 93, 2403, 922, 1159, 2403, 339, 768, 1246, 8300, 334, 1840, 9, 488, 339, 768, 1246, 547, 334, 5303, 9, 8857, 2017, 6378, 1324, 446, 25110, 883, 1454, 506, 562, 503, 282, 1329, 14, 272, 768, 1246, 547, 334, 8854, 9, 1910, 29284, 2047, 2793, 1133, 1172, 4983, 446, 7719, 506, 4628, 14, 272, 768, 1246, 547, 334, 5188, 9, 21909, 2876, 440, 1911, 14, 272, 408, 339, 768, 70, 3911, 14, 3735, 272, 768, 1418, 63, 1178, 14, 2886, 63, 2427, 272, 347, 5324, 8, 277, 12, 2403, 304, 267, 862, 26, 288, 340, 2403, 508, 283, 278, 356, 355, 922, 63, 344, 275, 1526, 63, 912, 63, 1045, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 1105, 459, 751, 63, 344, 418, 288, 587, 26, 355, 922, 63, 344, 275, 1109, 8, 1861, 9, 953, 922, 63, 1131, 275, 2876, 1685, 14, 1131, 971, 355, 1275, 1541, 8, 1899, 1685, 14, 344, 508, 922, 63, 344, 9, 953, 340, 1526, 63, 374, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 995, 922, 63, 344, 304, 355, 922, 63, 5693, 275, 1526, 63, 912, 63, 1045, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 1105, 459, 5693, 418, 2234, 340, 922, 63, 5693, 1137, 283, 14288, 7, 436, 1056, 14, 964, 14, 362, 360, 5693, 358, 365, 440, 488, 26, 490, 372, 298, 5556, 2793, 1133, 1172, 4983, 4765, 2004, 14, 2856, 63, 8854, 63, 1734, 25303, 1149, 2234, 1824, 275, 922, 12584, 14, 20945, 2821, 8, 1069, 14, 964, 9, 2234, 340, 1824, 14, 3502, 837, 490, 340, 922, 63, 1131, 14, 835, 837, 717, 922, 275, 922, 63, 1131, 14, 2246, 342, 9453, 862, 26, 1169, 367, 790, 12, 574, 315, 1056, 14, 964, 14, 1744, 837, 1816, 340, 574, 365, 440, 488, 436, 574, 1137, 8061, 2511, 340, 790, 508, 283, 2060, 356, 3147, 574, 275, 3550, 63, 2060, 63, 2227, 8, 585, 9, 3147, 1526, 63, 14691, 63, 452, 8, 751, 14, 344, 9, 199, 2511, 5371, 8, 751, 12, 790, 12, 574, 9, 18008, 922, 14, 5334, 63, 292, 275, 2197, 14, 2083, 14, 2131, 342, 1169, 1592, 14, 1730, 14, 3543, 342, 717, 871, 26864, 465, 325, 26, 1169, 901, 12, 574, 275, 664, 63, 2444, 63, 705, 8, 69, 9, 18008, 485, 1107, 275, 469, 1816, 283, 1188, 356, 21673, 435, 574, 435, 3546, 365, 2575, 3495, 4765, 1816, 283, 698, 356, 469, 2511, 283, 1302, 356, 2519, 8, 964, 12, 901, 680, 1302, 14, 505, 12, 2511, 283, 354, 356, 901, 1816, 789, 1169, 789, 18008, 372, 485, 1107, 12, 2004, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9453, 372, 488, 12, 2004, 14, 2856, 63, 1840, 63, 3593, 490, 587, 26, 717, 372, 298, 1918, 922, 1630, 440, 2187, 4765, 2004, 14, 2856, 63, 5188, 63, 4609, 63, 13945, 2234, 367, 901, 12, 2552, 315, 1824, 14, 2550, 14, 1744 ]
[ 327, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 295, 199, 646, 2197, 199, 199, 504, 7209, 492, 1056, 199, 504, 7209, 63, 1246, 492, 2004, 199, 504, 7209, 63, 3911, 1893, 492, 7337, 199, 504, 8335, 14, 2804, 492, 26864, 199, 504, 10380, 14, 4416, 492, 3550, 63, 2060, 63, 2227, 199, 199, 504, 1145, 492, 1592, 12, 1526, 63, 1178, 199, 504, 1145, 14, 992, 14, 751, 63, 1238, 492, 2876, 1685, 12, 664, 63, 751, 199, 504, 1145, 14, 992, 14, 751, 63, 1418, 63, 1238, 492, 1526, 63, 374, 63, 1178, 12, 1526, 63, 912, 63, 1045, 63, 1178, 12, 1526, 63, 14691, 63, 452, 12, 1526, 63, 1807, 63, 452, 199, 504, 1145, 14, 3112, 492, 289, 3911, 199, 504, 1145, 14, 3112, 14, 70, 3911, 14, 1246, 14, 705, 492, 664, 63, 2444, 63, 705, 199, 504, 1145, 14, 3112, 14, 70, 3911, 14, 3502, 492, 922, 465, 922, 12584, 199, 504, 1145, 14, 3112, 14, 70, 3911, 14, 3549, 14, 751, 492, 8437, 63, 751, 199, 199, 63, 2632, 275, 1994, 3707, 8316, 1861, 3524, 421, 199, 533, 2876, 8, 4031, 304, 272, 408, 272, 768, 1246, 469, 362, 93, 1182, 3707, 22075, 1861, 2372, 6770, 922, 1159, 2256, 272, 768, 1246, 985, 2876, 10332, 272, 768, 1246, 2448, 20123, 339, 768, 1246, 2567, 469, 1558, 93, 21527, 11003, 1526, 14, 272, 768, 1246, 2567, 9846, 469, 1001, 93, 10240, 13, 9846, 26, 267, 469, 288, 298, 11626, 582, 298, 8533, 30666, 2, 267, 789, 339, 768, 1246, 4098, 469, 1558, 93, 2403, 922, 1159, 2403, 339, 768, 1246, 8300, 334, 1840, 9, 469, 1558, 93, 666, 20123, 666, 14, 272, 768, 1246, 547, 334, 8854, 9, 1910, 29284, 2047, 2793, 1133, 1172, 4983, 14, 272, 768, 1246, 547, 334, 5303, 9, 1722, 25110, 883, 1454, 506, 562, 503, 1329, 272, 408, 339, 768, 70, 3911, 14, 3735, 272, 768, 1418, 63, 1178, 14, 2886, 63, 2427, 272, 347, 664, 8, 277, 12, 2403, 304, 267, 862, 26, 288, 340, 2403, 508, 283, 278, 356, 355, 922, 63, 344, 275, 1526, 63, 912, 63, 1045, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 1105, 459, 751, 63, 344, 418, 288, 587, 26, 355, 922, 63, 344, 275, 1109, 8, 1861, 9, 953, 340, 1526, 63, 374, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 995, 922, 63, 344, 304, 355, 922, 275, 664, 63, 751, 8, 751, 63, 344, 9, 2234, 372, 8437, 63, 751, 8, 751, 395, 2004, 14, 2856, 63, 1840, 63, 3593, 288, 587, 26, 355, 372, 298, 5556, 2793, 1133, 1172, 4983, 4765, 2004, 14, 2856, 63, 8854, 63, 1734, 25303, 1149, 267, 871, 1722, 26, 288, 372, 298, 4793, 883, 1454, 506, 562, 503, 282, 1329, 4765, 2004, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 339, 408, 272, 768, 1246, 469, 524, 93, 1182, 3707, 22075, 1861, 6162, 922, 2256, 272, 768, 1246, 985, 6162, 922, 2256, 272, 768, 1246, 2448, 20123, 272, 768, 1246, 7980, 9516, 339, 768, 1246, 2567, 469, 1558, 93, 21527, 11003, 1526, 14, 272, 768, 1246, 2567, 9846, 469, 1001, 93, 10240, 13, 9846, 26, 267, 469, 288, 298, 11626, 582, 298, 8533, 30666, 2, 267, 789, 339, 768, 1246, 4098, 469, 1558, 93, 2403, 922, 1159, 2403, 339, 768, 1246, 8300, 334, 1840, 9, 488, 339, 768, 1246, 547, 334, 5303, 9, 8857, 2017, 6378, 1324, 446, 25110, 883, 1454, 506, 562, 503, 282, 1329, 14, 272, 768, 1246, 547, 334, 8854, 9, 1910, 29284, 2047, 2793, 1133, 1172, 4983, 446, 7719, 506, 4628, 14, 272, 768, 1246, 547, 334, 5188, 9, 21909, 2876, 440, 1911, 14, 272, 408, 339, 768, 70, 3911, 14, 3735, 272, 768, 1418, 63, 1178, 14, 2886, 63, 2427, 272, 347, 5324, 8, 277, 12, 2403, 304, 267, 862, 26, 288, 340, 2403, 508, 283, 278, 356, 355, 922, 63, 344, 275, 1526, 63, 912, 63, 1045, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 1105, 459, 751, 63, 344, 418, 288, 587, 26, 355, 922, 63, 344, 275, 1109, 8, 1861, 9, 953, 922, 63, 1131, 275, 2876, 1685, 14, 1131, 971, 355, 1275, 1541, 8, 1899, 1685, 14, 344, 508, 922, 63, 344, 9, 953, 340, 1526, 63, 374, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 995, 922, 63, 344, 304, 355, 922, 63, 5693, 275, 1526, 63, 912, 63, 1045, 63, 1178, 8, 1069, 14, 2139, 459, 11626, 1105, 459, 5693, 418, 2234, 340, 922, 63, 5693, 1137, 283, 14288, 7, 436, 1056, 14, 964, 14, 362, 360, 5693, 358, 365, 440, 488, 26, 490, 372, 298, 5556, 2793, 1133, 1172, 4983, 4765, 2004, 14, 2856, 63, 8854, 63, 1734, 25303, 1149, 2234, 1824, 275, 922, 12584, 14, 20945, 2821, 8, 1069, 14, 964, 9, 2234, 340, 1824, 14, 3502, 837, 490, 340, 922, 63, 1131, 14, 835, 837, 717, 922, 275, 922, 63, 1131, 14, 2246, 342, 9453, 862, 26, 1169, 367, 790, 12, 574, 315, 1056, 14, 964, 14, 1744, 837, 1816, 340, 574, 365, 440, 488, 436, 574, 1137, 8061, 2511, 340, 790, 508, 283, 2060, 356, 3147, 574, 275, 3550, 63, 2060, 63, 2227, 8, 585, 9, 3147, 1526, 63, 14691, 63, 452, 8, 751, 14, 344, 9, 199, 2511, 5371, 8, 751, 12, 790, 12, 574, 9, 18008, 922, 14, 5334, 63, 292, 275, 2197, 14, 2083, 14, 2131, 342, 1169, 1592, 14, 1730, 14, 3543, 342, 717, 871, 26864, 465, 325, 26, 1169, 901, 12, 574, 275, 664, 63, 2444, 63, 705, 8, 69, 9, 18008, 485, 1107, 275, 469, 1816, 283, 1188, 356, 21673, 435, 574, 435, 3546, 365, 2575, 3495, 4765, 1816, 283, 698, 356, 469, 2511, 283, 1302, 356, 2519, 8, 964, 12, 901, 680, 1302, 14, 505, 12, 2511, 283, 354, 356, 901, 1816, 789, 1169, 789, 18008, 372, 485, 1107, 12, 2004, 14, 2856, 63, 5303, 63, 9439, 63, 6780, 9453, 372, 488, 12, 2004, 14, 2856, 63, 1840, 63, 3593, 490, 587, 26, 717, 372, 298, 1918, 922, 1630, 440, 2187, 4765, 2004, 14, 2856, 63, 5188, 63, 4609, 63, 13945, 2234, 367, 901, 12, 2552, 315, 1824, 14, 2550, 14, 1744, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ging/vcc
public/javascripts/fckeditor/editor/filemanager/connectors/py/fckcommands.py
93
6491
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http://www.gnu.org/licenses/gpl.html - GNU Lesser General Public License Version 2.1 or later (the "LGPL") http://www.gnu.org/licenses/lgpl.html - Mozilla Public License Version 1.1 or later (the "MPL") http://www.mozilla.org/MPL/MPL-1.1.html == END LICENSE == Connector for Python (CGI and WSGI). """ import os try: # Windows needs stdio set for binary mode for file upload to work. import msvcrt msvcrt.setmode (0, os.O_BINARY) # stdin = 0 msvcrt.setmode (1, os.O_BINARY) # stdout = 1 except ImportError: pass from fckutil import * from fckoutput import * import config as Config class GetFoldersCommandMixin (object): def getFolders(self, resourceType, currentFolder): """ Purpose: command to recieve a list of folders """ # Map the virtual path to our local server serverPath = mapServerFolder(self.userFilesFolder,currentFolder) s = """<Folders>""" # Open the folders node for someObject in os.listdir(serverPath): someObjectPath = mapServerFolder(serverPath, someObject) if os.path.isdir(someObjectPath): s += """<Folder name="%s" />""" % ( convertToXmlAttribute(someObject) ) s += """</Folders>""" # Close the folders node return s class GetFoldersAndFilesCommandMixin (object): def getFoldersAndFiles(self, resourceType, currentFolder): """ Purpose: command to recieve a list of folders and files """ # Map the virtual path to our local server serverPath = mapServerFolder(self.userFilesFolder,currentFolder) # Open the folders / files node folders = """<Folders>""" files = """<Files>""" for someObject in os.listdir(serverPath): someObjectPath = mapServerFolder(serverPath, someObject) if os.path.isdir(someObjectPath): folders += """<Folder name="%s" />""" % ( convertToXmlAttribute(someObject) ) elif os.path.isfile(someObjectPath): size = os.path.getsize(someObjectPath) files += """<File name="%s" size="%s" />""" % ( convertToXmlAttribute(someObject), os.path.getsize(someObjectPath) ) # Close the folders / files node folders += """</Folders>""" files += """</Files>""" return folders + files class CreateFolderCommandMixin (object): def createFolder(self, resourceType, currentFolder): """ Purpose: command to create a new folder """ errorNo = 0; errorMsg =''; if self.request.has_key("NewFolderName"): newFolder = self.request.get("NewFolderName", None) newFolder = sanitizeFolderName (newFolder) try: newFolderPath = mapServerFolder(self.userFilesFolder, combinePaths(currentFolder, newFolder)) self.createServerFolder(newFolderPath) except Exception, e: errorMsg = str(e).decode('iso-8859-1').encode('utf-8') # warning with encodigns!!! if hasattr(e,'errno'): if e.errno==17: #file already exists errorNo=0 elif e.errno==13: # permission denied errorNo = 103 elif e.errno==36 or e.errno==2 or e.errno==22: # filename too long / no such file / invalid name errorNo = 102 else: errorNo = 110 else: errorNo = 102 return self.sendErrorNode ( errorNo, errorMsg ) def createServerFolder(self, folderPath): "Purpose: physically creates a folder on the server" # No need to check if the parent exists, just create all hierachy try: permissions = Config.ChmodOnFolderCreate if not permissions: os.makedirs(folderPath) except AttributeError: #ChmodOnFolderCreate undefined permissions = 0755 if permissions: oldumask = os.umask(0) os.makedirs(folderPath,mode=0755) os.umask( oldumask ) class UploadFileCommandMixin (object): def uploadFile(self, resourceType, currentFolder): """ Purpose: command to upload files to server (same as FileUpload) """ errorNo = 0 if self.request.has_key("NewFile"): # newFile has all the contents we need newFile = self.request.get("NewFile", "") # Get the file name newFileName = newFile.filename newFileName = sanitizeFileName( newFileName ) newFileNameOnly = removeExtension(newFileName) newFileExtension = getExtension(newFileName).lower() allowedExtensions = Config.AllowedExtensions[resourceType] deniedExtensions = Config.DeniedExtensions[resourceType] if (allowedExtensions): # Check for allowed isAllowed = False if (newFileExtension in allowedExtensions): isAllowed = True elif (deniedExtensions): # Check for denied isAllowed = True if (newFileExtension in deniedExtensions): isAllowed = False else: # No extension limitations isAllowed = True if (isAllowed): # Upload to operating system # Map the virtual path to the local server path currentFolderPath = mapServerFolder(self.userFilesFolder, currentFolder) i = 0 while (True): newFilePath = os.path.join (currentFolderPath,newFileName) if os.path.exists(newFilePath): i += 1 newFileName = "%s(%04d).%s" % ( newFileNameOnly, i, newFileExtension ) errorNo= 201 # file renamed else: # Read file contents and write to the desired path (similar to php's move_uploaded_file) fout = file(newFilePath, 'wb') while (True): chunk = newFile.file.read(100000) if not chunk: break fout.write (chunk) fout.close() if os.path.exists ( newFilePath ): doChmod = False try: doChmod = Config.ChmodOnUpload permissions = Config.ChmodOnUpload except AttributeError: #ChmodOnUpload undefined doChmod = True permissions = 0755 if ( doChmod ): oldumask = os.umask(0) os.chmod( newFilePath, permissions ) os.umask( oldumask ) newFileUrl = self.webUserFilesFolder + currentFolder + newFileName return self.sendUploadResults( errorNo , newFileUrl, newFileName ) else: return self.sendUploadResults( errorNo = 203, customMsg = "Extension not allowed" ) else: return self.sendUploadResults( errorNo = 202, customMsg = "No File" )
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 2999, 199, 624, 202, 199, 4161, 1136, 27050, 446, 710, 1318, 8823, 367, 22026, 446, 1455, 921, 1544, 14, 70, 346, 7515, 14, 846, 202, 199, 7384, 334, 35, 9, 13004, 13, 9300, 481, 264, 9910, 331, 8256, 271, 20936, 1804, 78, 12198, 287, 2999, 199, 389, 16427, 5113, 508, 2999, 199, 31661, 1334, 314, 2895, 402, 1263, 402, 314, 2569, 12378, 737, 2195, 202, 199, 5095, 26, 2999, 199, 13, 1664, 1696, 1684, 844, 3394, 499, 503, 2945, 334, 1589, 298, 12006, 531, 202, 199, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 2999, 199, 13, 1664, 6401, 1696, 1684, 844, 3394, 499, 14, 17, 503, 2945, 334, 1589, 298, 44, 12006, 531, 202, 199, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 2999, 199, 13, 17728, 1684, 844, 3394, 413, 14, 17, 503, 2945, 334, 1589, 298, 3950, 531, 202, 199, 1014, 921, 1544, 14, 12102, 14, 1308, 15, 3950, 15, 3950, 13, 17, 14, 17, 14, 1360, 2999, 199, 389, 7729, 5113, 508, 2999, 199, 20476, 367, 2018, 334, 21337, 436, 9279, 680, 2999, 199, 624, 2999, 199, 646, 747, 202, 199, 893, 26, 327, 5417, 4839, 410, 3006, 663, 367, 3366, 818, 367, 570, 5802, 370, 1736, 14, 1223, 198, 646, 31756, 1223, 198, 706, 86, 16617, 14, 409, 632, 334, 16, 12, 747, 14, 47, 63, 13246, 9, 327, 9009, 221, 275, 378, 1223, 198, 706, 86, 16617, 14, 409, 632, 334, 17, 12, 747, 14, 47, 63, 13246, 9, 327, 3839, 275, 413, 202, 199, 2590, 3545, 26, 1223, 198, 1529, 2999, 199, 504, 289, 346, 1974, 492, 627, 202, 199, 504, 289, 346, 1199, 492, 627, 202, 199, 646, 1101, 465, 4094, 2999, 199, 533, 2372, 7850, 83, 3110, 4256, 334, 785, 304, 1223, 198, 318, 664, 7850, 83, 8, 277, 12, 2073, 804, 12, 1453, 7850, 304, 4122, 198, 624, 4122, 198, 14959, 4070, 26, 1414, 370, 295, 559, 4754, 282, 769, 402, 16533, 4122, 198, 624, 4122, 198, 3, 9672, 314, 5791, 931, 370, 4154, 2257, 1654, 4122, 198, 1000, 2042, 275, 2341, 3120, 7850, 8, 277, 14, 751, 5535, 7850, 12, 1818, 7850, 9, 4122, 198, 83, 275, 8894, 7850, 83, 11193, 198, 327, 3232, 314, 16533, 1031, 4122, 198, 509, 2005, 1692, 315, 747, 14, 7374, 8, 1000, 2042, 304, 7903, 198, 3972, 1692, 2042, 275, 2341, 3120, 7850, 8, 1000, 2042, 12, 2005, 1692, 9, 7903, 198, 692, 747, 14, 515, 14, 6027, 8, 3972, 1692, 2042, 304, 13610, 198, 83, 847, 8894, 7850, 536, 5961, 83, 2, 7082, 624, 450, 334, 28087, 198, 21880, 8672, 1646, 8, 3972, 1692, 9, 28087, 198, 9, 4122, 198, 83, 847, 408, 1108, 7850, 83, 11193, 327, 15524, 314, 16533, 1031, 4122, 198, 1107, 308, 2999, 199, 533, 2372, 7850, 83, 3325, 5535, 3110, 4256, 334, 785, 304, 1223, 198, 318, 664, 7850, 83, 3325, 5535, 8, 277, 12, 2073, 804, 12, 1453, 7850, 304, 4122, 198, 624, 4122, 198, 14959, 4070, 26, 1414, 370, 295, 559, 4754, 282, 769, 402, 16533, 436, 1584, 4122, 198, 624, 4122, 198, 3, 9672, 314, 5791, 931, 370, 4154, 2257, 1654, 4122, 198, 1000, 2042, 275, 2341, 3120, 7850, 8, 277, 14, 751, 5535, 7850, 12, 1818, 7850, 9, 4122, 198, 3, 3232, 314, 16533, 1182, 1584, 1031, 4122, 198, 15171, 275, 8894, 7850, 83, 11193, 4122, 198, 1725, 275, 8894, 5535, 11193, 4122, 198, 509, 2005, 1692, 315, 747, 14, 7374, 8, 1000, 2042, 304, 7903, 198, 3972, 1692, 2042, 275, 2341, 3120, 7850, 8, 1000, 2042, 12, 2005, 1692, 9, 7903, 198, 692, 747, 14, 515, 14, 6027, 8, 3972, 1692, 2042, 304, 13610, 198, 15171, 847, 8894, 7850, 536, 5961, 83, 2, 7082, 624, 450, 334, 28087, 198, 21880, 8672, 1646, 8, 3972, 1692, 9, 28087, 198, 9, 7903, 198, 4164, 747, 14, 515, 14, 6292, 8, 3972, 1692, 2042, 304, 13610, 198, 890, 275, 747, 14, 515, 14, 20733, 8, 3972, 1692, 2042, 9, 13610, 198, 1725, 847, 8894, 1173, 536, 5961, 83, 2, 1568, 5961, 83, 2, 7082, 624, 450, 334, 28087, 198, 21880, 8672, 1646, 8, 3972, 1692, 395, 28087, 198, 736, 14, 515, 14, 20733, 8, 3972, 1692, 2042, 9, 28087, 198, 9, 4122, 198, 3, 15524, 314, 16533, 1182, 1584, 1031, 4122, 198, 15171, 847, 408, 1108, 7850, 83, 11193, 4122, 198, 1725, 847, 408, 1108, 5535, 11193, 4122, 198, 1107, 16533, 435, 1584, 2999, 199, 533, 2790, 7850, 3110, 4256, 334, 785, 304, 1223, 198, 318, 1218, 7850, 8, 277, 12, 2073, 804, 12, 1453, 7850, 304, 4122, 198, 624, 4122, 198, 14959, 4070, 26, 1414, 370, 1218, 282, 892, 4922, 4122, 198, 624, 4122, 198, 705, 1944, 275, 378, 27, 1125, 6173, 275, 891, 27, 4122, 198, 692, 291, 14, 1069, 14, 1989, 63, 498, 480, 4665, 7850, 985, 2349, 7903, 198, 1222, 7850, 275, 291, 14, 1069, 14, 362, 480, 4665, 7850, 985, 401, 488, 9, 7903, 198, 1222, 7850, 275, 21077, 7850, 985, 334, 1222, 7850, 9, 7903, 198, 893, 26, 13610, 198, 1222, 7850, 2042, 275, 2341, 3120, 7850, 8, 277, 14, 751, 5535, 7850, 12, 13323, 11804, 8, 1818, 7850, 12, 892, 7850, 430, 13610, 198, 277, 14, 981, 3120, 7850, 8, 1222, 7850, 2042, 9, 7903, 198, 2590, 2186, 12, 325, 26, 13610, 198, 705, 6173, 275, 620, 8, 69, 680, 2708, 360, 4595, 13, 4830, 13, 17, 1959, 2143, 360, 1624, 13, 24, 358, 327, 5721, 543, 655, 331, 18367, 561, 21512, 13610, 198, 692, 2688, 8, 69, 2584, 7931, 735, 19744, 198, 692, 325, 14, 7931, 389, 1196, 26, 327, 493, 2575, 3495, 28087, 198, 705, 1944, 29, 16, 19744, 198, 4164, 325, 14, 7931, 389, 969, 26, 327, 4983, 23355, 28087, 198, 705, 1944, 275, 22363, 19744, 198, 4164, 325, 14, 7931, 389, 1344, 503, 325, 14, 7931, 389, 18, 503, 325, 14, 7931, 389, 1081, 26, 327, 1788, 4634, 1846, 1182, 949, 4066, 570, 1182, 3866, 536, 28087, 198, 705, 1944, 275, 12996, 13610, 198, 2836, 26, 19744, 198, 705, 1944, 275, 16814, 4122, 198, 2836, 26, 7903, 198, 705, 1944 ]
[ 2647, 15, 1393, 15, 1813, 2366, 2999, 199, 624, 202, 199, 4161, 1136, 27050, 446, 710, 1318, 8823, 367, 22026, 446, 1455, 921, 1544, 14, 70, 346, 7515, 14, 846, 202, 199, 7384, 334, 35, 9, 13004, 13, 9300, 481, 264, 9910, 331, 8256, 271, 20936, 1804, 78, 12198, 287, 2999, 199, 389, 16427, 5113, 508, 2999, 199, 31661, 1334, 314, 2895, 402, 1263, 402, 314, 2569, 12378, 737, 2195, 202, 199, 5095, 26, 2999, 199, 13, 1664, 1696, 1684, 844, 3394, 499, 503, 2945, 334, 1589, 298, 12006, 531, 202, 199, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 2999, 199, 13, 1664, 6401, 1696, 1684, 844, 3394, 499, 14, 17, 503, 2945, 334, 1589, 298, 44, 12006, 531, 202, 199, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 2999, 199, 13, 17728, 1684, 844, 3394, 413, 14, 17, 503, 2945, 334, 1589, 298, 3950, 531, 202, 199, 1014, 921, 1544, 14, 12102, 14, 1308, 15, 3950, 15, 3950, 13, 17, 14, 17, 14, 1360, 2999, 199, 389, 7729, 5113, 508, 2999, 199, 20476, 367, 2018, 334, 21337, 436, 9279, 680, 2999, 199, 624, 2999, 199, 646, 747, 202, 199, 893, 26, 327, 5417, 4839, 410, 3006, 663, 367, 3366, 818, 367, 570, 5802, 370, 1736, 14, 1223, 198, 646, 31756, 1223, 198, 706, 86, 16617, 14, 409, 632, 334, 16, 12, 747, 14, 47, 63, 13246, 9, 327, 9009, 221, 275, 378, 1223, 198, 706, 86, 16617, 14, 409, 632, 334, 17, 12, 747, 14, 47, 63, 13246, 9, 327, 3839, 275, 413, 202, 199, 2590, 3545, 26, 1223, 198, 1529, 2999, 199, 504, 289, 346, 1974, 492, 627, 202, 199, 504, 289, 346, 1199, 492, 627, 202, 199, 646, 1101, 465, 4094, 2999, 199, 533, 2372, 7850, 83, 3110, 4256, 334, 785, 304, 1223, 198, 318, 664, 7850, 83, 8, 277, 12, 2073, 804, 12, 1453, 7850, 304, 4122, 198, 624, 4122, 198, 14959, 4070, 26, 1414, 370, 295, 559, 4754, 282, 769, 402, 16533, 4122, 198, 624, 4122, 198, 3, 9672, 314, 5791, 931, 370, 4154, 2257, 1654, 4122, 198, 1000, 2042, 275, 2341, 3120, 7850, 8, 277, 14, 751, 5535, 7850, 12, 1818, 7850, 9, 4122, 198, 83, 275, 8894, 7850, 83, 11193, 198, 327, 3232, 314, 16533, 1031, 4122, 198, 509, 2005, 1692, 315, 747, 14, 7374, 8, 1000, 2042, 304, 7903, 198, 3972, 1692, 2042, 275, 2341, 3120, 7850, 8, 1000, 2042, 12, 2005, 1692, 9, 7903, 198, 692, 747, 14, 515, 14, 6027, 8, 3972, 1692, 2042, 304, 13610, 198, 83, 847, 8894, 7850, 536, 5961, 83, 2, 7082, 624, 450, 334, 28087, 198, 21880, 8672, 1646, 8, 3972, 1692, 9, 28087, 198, 9, 4122, 198, 83, 847, 408, 1108, 7850, 83, 11193, 327, 15524, 314, 16533, 1031, 4122, 198, 1107, 308, 2999, 199, 533, 2372, 7850, 83, 3325, 5535, 3110, 4256, 334, 785, 304, 1223, 198, 318, 664, 7850, 83, 3325, 5535, 8, 277, 12, 2073, 804, 12, 1453, 7850, 304, 4122, 198, 624, 4122, 198, 14959, 4070, 26, 1414, 370, 295, 559, 4754, 282, 769, 402, 16533, 436, 1584, 4122, 198, 624, 4122, 198, 3, 9672, 314, 5791, 931, 370, 4154, 2257, 1654, 4122, 198, 1000, 2042, 275, 2341, 3120, 7850, 8, 277, 14, 751, 5535, 7850, 12, 1818, 7850, 9, 4122, 198, 3, 3232, 314, 16533, 1182, 1584, 1031, 4122, 198, 15171, 275, 8894, 7850, 83, 11193, 4122, 198, 1725, 275, 8894, 5535, 11193, 4122, 198, 509, 2005, 1692, 315, 747, 14, 7374, 8, 1000, 2042, 304, 7903, 198, 3972, 1692, 2042, 275, 2341, 3120, 7850, 8, 1000, 2042, 12, 2005, 1692, 9, 7903, 198, 692, 747, 14, 515, 14, 6027, 8, 3972, 1692, 2042, 304, 13610, 198, 15171, 847, 8894, 7850, 536, 5961, 83, 2, 7082, 624, 450, 334, 28087, 198, 21880, 8672, 1646, 8, 3972, 1692, 9, 28087, 198, 9, 7903, 198, 4164, 747, 14, 515, 14, 6292, 8, 3972, 1692, 2042, 304, 13610, 198, 890, 275, 747, 14, 515, 14, 20733, 8, 3972, 1692, 2042, 9, 13610, 198, 1725, 847, 8894, 1173, 536, 5961, 83, 2, 1568, 5961, 83, 2, 7082, 624, 450, 334, 28087, 198, 21880, 8672, 1646, 8, 3972, 1692, 395, 28087, 198, 736, 14, 515, 14, 20733, 8, 3972, 1692, 2042, 9, 28087, 198, 9, 4122, 198, 3, 15524, 314, 16533, 1182, 1584, 1031, 4122, 198, 15171, 847, 408, 1108, 7850, 83, 11193, 4122, 198, 1725, 847, 408, 1108, 5535, 11193, 4122, 198, 1107, 16533, 435, 1584, 2999, 199, 533, 2790, 7850, 3110, 4256, 334, 785, 304, 1223, 198, 318, 1218, 7850, 8, 277, 12, 2073, 804, 12, 1453, 7850, 304, 4122, 198, 624, 4122, 198, 14959, 4070, 26, 1414, 370, 1218, 282, 892, 4922, 4122, 198, 624, 4122, 198, 705, 1944, 275, 378, 27, 1125, 6173, 275, 891, 27, 4122, 198, 692, 291, 14, 1069, 14, 1989, 63, 498, 480, 4665, 7850, 985, 2349, 7903, 198, 1222, 7850, 275, 291, 14, 1069, 14, 362, 480, 4665, 7850, 985, 401, 488, 9, 7903, 198, 1222, 7850, 275, 21077, 7850, 985, 334, 1222, 7850, 9, 7903, 198, 893, 26, 13610, 198, 1222, 7850, 2042, 275, 2341, 3120, 7850, 8, 277, 14, 751, 5535, 7850, 12, 13323, 11804, 8, 1818, 7850, 12, 892, 7850, 430, 13610, 198, 277, 14, 981, 3120, 7850, 8, 1222, 7850, 2042, 9, 7903, 198, 2590, 2186, 12, 325, 26, 13610, 198, 705, 6173, 275, 620, 8, 69, 680, 2708, 360, 4595, 13, 4830, 13, 17, 1959, 2143, 360, 1624, 13, 24, 358, 327, 5721, 543, 655, 331, 18367, 561, 21512, 13610, 198, 692, 2688, 8, 69, 2584, 7931, 735, 19744, 198, 692, 325, 14, 7931, 389, 1196, 26, 327, 493, 2575, 3495, 28087, 198, 705, 1944, 29, 16, 19744, 198, 4164, 325, 14, 7931, 389, 969, 26, 327, 4983, 23355, 28087, 198, 705, 1944, 275, 22363, 19744, 198, 4164, 325, 14, 7931, 389, 1344, 503, 325, 14, 7931, 389, 18, 503, 325, 14, 7931, 389, 1081, 26, 327, 1788, 4634, 1846, 1182, 949, 4066, 570, 1182, 3866, 536, 28087, 198, 705, 1944, 275, 12996, 13610, 198, 2836, 26, 19744, 198, 705, 1944, 275, 16814, 4122, 198, 2836, 26, 7903, 198, 705, 1944, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
KaranToor/MA450
google-cloud-sdk/.install/.backup/lib/surface/functions/deploy.py
2
16199
# Copyright 2015 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """'functions deploy' command.""" import argparse import httplib import os import random import string from apitools.base.py import exceptions as apitools_exceptions from googlecloudsdk.api_lib.compute import utils from googlecloudsdk.api_lib.functions import cloud_storage as storage from googlecloudsdk.api_lib.functions import exceptions from googlecloudsdk.api_lib.functions import operations from googlecloudsdk.api_lib.functions import util from googlecloudsdk.calliope import arg_parsers from googlecloudsdk.calliope import base from googlecloudsdk.command_lib.functions.deploy import util as deploy_util from googlecloudsdk.core import properties from googlecloudsdk.core import resources from googlecloudsdk.core.console import progress_tracker from googlecloudsdk.core.util import archive from googlecloudsdk.core.util import files as file_utils def _FunctionArgs(parser): """Add arguments specyfying functions behavior to the parser.""" parser.add_argument( 'name', help='Intended name of the new function.', type=util.ValidateFunctionNameOrRaise) memory = parser.add_argument( '--memory', help='Amount of memory available to the function.', type=arg_parsers.BinarySize( suggested_binary_size_scales=['KB', 'MB', 'MiB', 'GB', 'GiB'])) memory.detailed_help = """\ The amount of memory allocated to your function. Allowed values are: 128MB, 256MB, 512MB, and 1024MB. """ parser.add_argument( '--timeout', help=('The function execution timeout, e.g. 30s for 30 seconds. ' 'Defaults to 60 seconds.'), type=arg_parsers.Duration(lower_bound='1s')) def _SourceCodeArgs(parser): """Add arguments specyfying functions source code to the parser.""" path_group = parser.add_mutually_exclusive_group() path_group.add_argument( '--source', help=argparse.SUPPRESS) path_group.add_argument( '--local-path', help=('Path to local directory with source code. Required with ' '--stage-bucket flag.')) path_group.add_argument( '--source-path', help=('Path to directory with source code in Cloud Source ' 'Repositories, when you specify this parameter --source-url flag ' 'is required.')) source_group = parser.add_mutually_exclusive_group() source_group.add_argument( '--bucket', help=argparse.SUPPRESS, type=util.ValidateAndStandarizeBucketUriOrRaise) source_group.add_argument( '--stage-bucket', help=('Name of Google Cloud Storage bucket in which source code will ' 'be stored. Required if a function is deployed from a local ' 'directory.'), type=util.ValidateAndStandarizeBucketUriOrRaise) source_group.add_argument( '--source-url', help=('The Url of a remote repository that holds the function being ' 'deployed. It is of the form: ' 'https://source.developers.google.com/p/{project_id}/' 'r/{repo_name}/, where you should substitute your data for ' 'values inside the curly brackets. You can omit "r/{repo_name}/" ' 'in which case the "default" repository is taken. ' 'One of the parameters --source-revision, --source-branch, ' 'or --source-tag can be given to specify the version in the ' 'repository. If none of them are provided, the last revision ' 'from the main branch is used. If this parameter is given, ' 'the parameter --source is required and describes the path ' 'inside the repository.')) source_version_group = parser.add_mutually_exclusive_group() source_version_group.add_argument( '--source-revision', help=('The revision ID (for instance, git commit hash) that will be ' 'used to get the source code of the function. Can be specified ' 'only together with --source-url parameter.')) source_version_group.add_argument( '--source-branch', help=('The branch that will be used to get the source code of the ' 'function. The most recent revision on this branch will be ' 'used. Can be specified only together with --source-url ' 'parameter. If not specified defaults to `main`.')) source_version_group.add_argument( '--source-tag', help=('The revision tag for the source that will be used as the source ' 'code of the function. Can be specified only together with ' '--source-url parameter.')) entry_point = parser.add_argument( '--entry-point', help='Specified function to run when triggering event happens.', type=util.ValidateEntryPointNameOrRaise) entry_point.detailed_help = ( 'By default when a Google Cloud Function is triggered, it executes a ' 'JavaScript function with the same name. Or, if it cannot find a ' 'function with the same name, it executes a function named `function`. ' 'You can use this flag to override the default behavior, by specifying ' 'the name of a JavaScript function that will be executed when the ' 'Google Cloud Function is triggered.' ) def _TriggerArgs(parser): """Add arguments specyfying functions trigger to the parser.""" trigger_group = parser.add_mutually_exclusive_group(required=True) trigger_group.add_argument( '--trigger-topic', help=('Name of Pub/Sub topic. Every message published in this topic ' 'will trigger function execution with message contents passed as ' 'input data.'), type=util.ValidatePubsubTopicNameOrRaise) trigger_group.add_argument( '--trigger-gs-uri', help=argparse.SUPPRESS, type=util.ValidateAndStandarizeBucketUriOrRaise) trigger_group.add_argument( '--trigger-bucket', help=('Google Cloud Storage bucket name. Every change in files in this ' 'bucket will trigger function execution.'), type=util.ValidateAndStandarizeBucketUriOrRaise) trigger_http = trigger_group.add_argument( '--trigger-http', action='store_true', help='Associates an HTTP endpoint with this function.') trigger_http.detailed_help = ( 'Function will be assigned an endpoint, which you can view by using ' 'the `describe` command. Any HTTP request (of a supported type) to the ' 'endpoint will trigger function execution. Supported HTTP request ' 'types are: POST, PUT, GET, DELETE, and OPTIONS.') trigger_group.add_argument( '--trigger-provider', metavar='PROVIDER', choices=sorted(util.trigger_provider_registry.ProvidersLabels()), help=('Trigger this function in response to an event in another ' 'service. For a list of acceptable values, call `gcloud ' 'functions event-types list`.'), ) trigger_provider_spec_group = parser.add_argument_group() # The validation performed by argparse is incomplete, as the set of valid # provider/event combinations is limited. This should be more thoroughly # validated at runtime. trigger_provider_spec_group.add_argument( '--trigger-event', metavar='EVENT_TYPE', choices=['topic.publish', 'object.change', 'user.create', 'user.delete', 'data.write'], help=('Specifies which action should trigger the function. If omitted, ' 'a default EVENT_TYPE for --trigger-provider will be used. For a ' 'list of acceptable values, call functions event_types list.'), ) # check later as type of applicable input depends on options above trigger_provider_spec_group.add_argument( '--trigger-resource', metavar='RESOURCE', help=('Specifies which resource from --trigger-provider is being ' 'observed. E.g. if --trigger-provider is cloud.storage, ' '--trigger-resource must be a bucket name. For a list of ' 'expected resources, call functions event_types list.'), ) class Deploy(base.Command): """Creates a new function or updates an existing one.""" @staticmethod def Args(parser): """Register flags for this command.""" _FunctionArgs(parser) _SourceCodeArgs(parser) _TriggerArgs(parser) @util.CatchHTTPErrorRaiseHTTPException def _GetExistingFunction(self, name): client = self.context['functions_client'] messages = self.context['functions_messages'] try: # TODO(user): Use resources.py here after b/21908671 is fixed. # We got response for a get request so a function exists. return client.projects_locations_functions.Get( messages.CloudfunctionsProjectsLocationsFunctionsGetRequest( name=name)) except apitools_exceptions.HttpError as error: if error.status_code == httplib.NOT_FOUND: # The function has not been found. return None raise def _GenerateRemoteZipFileName(self, args): sufix = ''.join(random.choice(string.ascii_lowercase) for _ in range(12)) return '{0}-{1}-{2}.zip'.format(args.region, args.name, sufix) def _UploadFile(self, source, target): return storage.Upload(source, target) def _CreateZipFile(self, tmp_dir, args): zip_file_name = os.path.join(tmp_dir, 'fun.zip') local_path = deploy_util.GetLocalPath(args) try: archive.MakeZipFromDir(zip_file_name, local_path) except ValueError as e: raise exceptions.FunctionsError( 'Error creating a ZIP archive with the source code ' 'for directory {0}: {1}'.format(local_path, str(e))) return zip_file_name def _EventTrigger(self, trigger_provider, trigger_event, trigger_resource): messages = self.context['functions_messages'] event_trigger = messages.EventTrigger() event_type_ref = resources.REGISTRY.Parse( None, params={ 'triggerProvider': trigger_provider, 'triggerEvent': trigger_event }, collection='cloudfunctions.providers.event_types' ) event_trigger.eventType = event_type_ref.RelativeName() event_trigger.resource = ( deploy_util.ConvertTriggerArgsToRelativeName( trigger_provider, trigger_event, trigger_resource)) return event_trigger def _PrepareFunctionWithoutSources( self, name, entry_point, timeout_sec, trigger_http, trigger_params): """Creates a function object without filling in the sources properties. Args: name: str, name of the function (resource). entry_point: str, name of the function (in deployed code) to be executed. timeout_sec: int, maximum time allowed for function execution, in seconds. trigger_http: bool, indicates whether function should have a HTTPS trigger; when truthy trigger_params argument is ignored. trigger_params: None or dict from str to str, the dict is assmed to contain exactly the following keys: trigger_provider, trigger_event, trigger_resource. Returns: The specified function with its description and configured filter. """ messages = self.context['functions_messages'] function = messages.CloudFunction() function.name = name if entry_point: function.entryPoint = entry_point if timeout_sec: function.timeout = str(timeout_sec) + 's' if trigger_http: function.httpsTrigger = messages.HTTPSTrigger() else: function.eventTrigger = self._EventTrigger(**trigger_params) return function def _DeployFunction(self, name, location, args, deploy_method, trigger_params): function = self._PrepareFunctionWithoutSources( name, args.entry_point, args.timeout, args.trigger_http, trigger_params) if args.source_url: messages = self.context['functions_messages'] source_path = args.source or args.source_path source_branch = args.source_branch or 'main' function.sourceRepository = messages.SourceRepository( tag=args.source_tag, branch=source_branch, revision=args.source_revision, repositoryUrl=args.source_url, sourcePath=source_path) else: function.sourceArchiveUrl = self._PrepareSourcesOnGcs(args) memory_mb = utils.BytesToMb(args.memory) if memory_mb: function.availableMemoryMb = memory_mb return deploy_method(location, function) def _PrepareSourcesOnGcs(self, args): remote_zip_file = self._GenerateRemoteZipFileName(args) stage_bucket = args.bucket or args.stage_bucket gcs_url = storage.BuildRemoteDestination(stage_bucket, remote_zip_file) with file_utils.TemporaryDirectory() as tmp_dir: zip_file = self._CreateZipFile(tmp_dir, args) if self._UploadFile(zip_file, gcs_url) != 0: raise exceptions.FunctionsError( 'Failed to upload the function source code to the bucket {0}' .format(stage_bucket)) return gcs_url @util.CatchHTTPErrorRaiseHTTPException def _CreateFunction(self, location, function): client = self.context['functions_client'] messages = self.context['functions_messages'] # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_locations_functions.Create( messages.CloudfunctionsProjectsLocationsFunctionsCreateRequest( location=location, cloudFunction=function)) with progress_tracker.ProgressTracker( 'Deploying function (may take a while - up to 2 minutes)'): operations.Wait(op, messages, client) return self._GetExistingFunction(function.name) @util.CatchHTTPErrorRaiseHTTPException def _UpdateFunction(self, unused_location, function): client = self.context['functions_client'] messages = self.context['functions_messages'] # TODO(user): Use resources.py here after b/21908671 is fixed. op = client.projects_locations_functions.Update(function) with progress_tracker.ProgressTracker( 'Deploying function (may take a while - up to 2 minutes)'): operations.Wait(op, messages, client) return self._GetExistingFunction(function.name) def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: The specified function with its description and configured filter. Raises: FunctionsError if command line parameters are not valid. """ # TODO(b/24723761): This should be invoked as a hook method after arguments # are parsed, but unfortunately gcloud framework doesn't support such a # hook. trigger_params = deploy_util.DeduceAndCheckArgs(args) project = properties.VALUES.core.project.Get(required=True) registry = self.context['registry'] location_ref = registry.Parse( args.region, params={'projectsId': project}, collection='cloudfunctions.projects.locations') location = location_ref.RelativeName() function_ref = registry.Parse( args.name, params={'projectsId': project, 'locationsId': args.region}, collection='cloudfunctions.projects.locations.functions') function_url = function_ref.RelativeName() function = self._GetExistingFunction(function_url) if function is None: return self._DeployFunction(function_url, location, args, self._CreateFunction, trigger_params) else: return self._DeployFunction(function_url, location, args, self._UpdateFunction, trigger_params)
apache-2.0
[ 3, 1898, 6900, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 7, 5777, 12287, 7, 1414, 1041, 199, 646, 7534, 199, 646, 8809, 199, 646, 747, 199, 646, 2196, 199, 646, 1059, 199, 199, 504, 2771, 390, 5998, 14, 1095, 14, 647, 492, 4967, 465, 2771, 390, 5998, 63, 3924, 199, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 3357, 492, 3778, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 8002, 63, 3494, 465, 4887, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 4967, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 5331, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 4884, 199, 504, 6233, 29691, 6341, 14, 915, 317, 13458, 492, 1680, 63, 11531, 199, 504, 6233, 29691, 6341, 14, 915, 317, 13458, 492, 1300, 199, 504, 6233, 29691, 6341, 14, 1531, 63, 773, 14, 5777, 14, 11060, 492, 4884, 465, 12287, 63, 1974, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 4382, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 5944, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 6614, 492, 6696, 63, 8877, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 6359, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 1584, 465, 570, 63, 1208, 421, 199, 318, 485, 3481, 6213, 8, 2087, 304, 523, 408, 1123, 2368, 3158, 89, 1399, 316, 3423, 5953, 370, 314, 1798, 1041, 523, 1798, 14, 525, 63, 2094, 8, 489, 283, 354, 297, 1720, 534, 23910, 536, 402, 314, 892, 805, 3130, 489, 730, 29, 1974, 14, 12584, 3481, 985, 2844, 18111, 9, 523, 4402, 275, 1798, 14, 525, 63, 2094, 8, 489, 2850, 4844, 297, 1720, 534, 18785, 402, 4402, 2808, 370, 314, 805, 3130, 489, 730, 29, 1273, 63, 11531, 14, 6636, 2320, 8, 881, 25697, 63, 3008, 63, 890, 63, 30832, 2968, 12780, 297, 283, 4567, 297, 283, 14738, 34, 297, 283, 6487, 297, 283, 39, 17587, 5156, 523, 4402, 14, 19170, 63, 3437, 275, 9638, 272, 710, 5982, 402, 4402, 17659, 370, 2195, 805, 14, 339, 27301, 1338, 787, 26, 7960, 4567, 12, 7633, 4567, 12, 10574, 4567, 12, 436, 6619, 4567, 14, 272, 408, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 2593, 297, 489, 1720, 7782, 1918, 805, 6451, 2653, 12, 325, 14, 71, 14, 4233, 83, 367, 4233, 4696, 14, 283, 288, 283, 16986, 370, 5212, 4696, 8038, 489, 730, 29, 1273, 63, 11531, 14, 13283, 8, 2325, 63, 3556, 534, 17, 83, 1333, 421, 199, 318, 485, 2980, 3034, 6213, 8, 2087, 304, 523, 408, 1123, 2368, 3158, 89, 1399, 316, 3423, 1350, 1233, 370, 314, 1798, 1041, 523, 931, 63, 923, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 523, 931, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1365, 297, 489, 1720, 29, 18978, 14, 24023, 9, 523, 931, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1832, 13, 515, 297, 489, 1720, 7782, 2042, 370, 2257, 2082, 543, 1350, 1233, 14, 11105, 543, 283, 288, 2850, 8614, 13, 4623, 3305, 12459, 523, 931, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1365, 13, 515, 297, 489, 1720, 7782, 2042, 370, 2082, 543, 1350, 1233, 315, 8142, 5800, 283, 288, 283, 11334, 15529, 12, 1380, 1265, 4165, 642, 2725, 1553, 1365, 13, 633, 3305, 283, 288, 283, 374, 1415, 12459, 523, 1350, 63, 923, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 523, 1350, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 4623, 297, 489, 1720, 29, 18978, 14, 24023, 12, 489, 730, 29, 1974, 14, 12584, 3325, 18736, 285, 794, 12311, 14014, 2844, 18111, 9, 523, 1350, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 8614, 13, 4623, 297, 489, 1720, 7782, 985, 402, 4475, 8142, 10533, 5315, 315, 1314, 1350, 1233, 911, 283, 288, 283, 1235, 5489, 14, 11105, 340, 282, 805, 365, 26181, 687, 282, 2257, 283, 288, 283, 3619, 8038, 489, 730, 29, 1974, 14, 12584, 3325, 18736, 285, 794, 12311, 14014, 2844, 18111, 9, 523, 1350, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1365, 13, 633, 297, 489, 1720, 7782, 1918, 20503, 402, 282, 3982, 7611, 626, 15164, 314, 805, 3769, 283, 288, 283, 11060, 379, 14, 2779, 365, 402, 314, 1824, 26, 283, 288, 283, 2859, 921, 1365, 14, 23826, 14, 3098, 14, 957, 15, 80, 5321, 1715, 63, 344, 93, 4805, 288, 283, 82, 5321, 3417, 63, 354, 5995, 12, 2382, 1265, 1077, 23080, 2195, 666, 367, 283, 288, 283, 1459, 6272, 314, 1094, 590, 21873, 14, 2047, 883, 19413, 298, 82, 5321, 3417, 63, 354, 5995, 2, 283, 288, 283, 262, 1314, 1930, 314, 298, 885, 2, 7611, 365, 9394, 14, 283, 288, 283, 4395, 402, 314, 2633, 1553, 1365, 13, 5792, 12, 1553, 1365, 13, 4694, 12, 283, 288, 283, 269, 1553, 1365, 13, 1450, 883, 506, 1627, 370, 4165, 314, 1015, 315, 314, 283, 288, 283, 8421, 14, 982, 7179, 402, 3062, 787, 2741, 12, 314, 2061, 6974, 283, 288, 283, 504, 314, 2446, 5246, 365, 1202, 14, 982, 642, 2725, 365, 1627, 12, 283, 288, 283, 1589, 2725, 1553, 1365, 365, 1415, 436, 23369, 314, 931, 283, 288, 283, 17183, 314, 7611, 12459, 523, 1350, 63, 1023, 63, 923, 275, 1798, 14, 525, 63, 25024 ]
[ 1898, 6900, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 7, 5777, 12287, 7, 1414, 1041, 199, 646, 7534, 199, 646, 8809, 199, 646, 747, 199, 646, 2196, 199, 646, 1059, 199, 199, 504, 2771, 390, 5998, 14, 1095, 14, 647, 492, 4967, 465, 2771, 390, 5998, 63, 3924, 199, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 3357, 492, 3778, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 8002, 63, 3494, 465, 4887, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 4967, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 5331, 199, 504, 6233, 29691, 6341, 14, 1246, 63, 773, 14, 5777, 492, 4884, 199, 504, 6233, 29691, 6341, 14, 915, 317, 13458, 492, 1680, 63, 11531, 199, 504, 6233, 29691, 6341, 14, 915, 317, 13458, 492, 1300, 199, 504, 6233, 29691, 6341, 14, 1531, 63, 773, 14, 5777, 14, 11060, 492, 4884, 465, 12287, 63, 1974, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 4382, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 5944, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 6614, 492, 6696, 63, 8877, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 6359, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 1584, 465, 570, 63, 1208, 421, 199, 318, 485, 3481, 6213, 8, 2087, 304, 523, 408, 1123, 2368, 3158, 89, 1399, 316, 3423, 5953, 370, 314, 1798, 1041, 523, 1798, 14, 525, 63, 2094, 8, 489, 283, 354, 297, 1720, 534, 23910, 536, 402, 314, 892, 805, 3130, 489, 730, 29, 1974, 14, 12584, 3481, 985, 2844, 18111, 9, 523, 4402, 275, 1798, 14, 525, 63, 2094, 8, 489, 2850, 4844, 297, 1720, 534, 18785, 402, 4402, 2808, 370, 314, 805, 3130, 489, 730, 29, 1273, 63, 11531, 14, 6636, 2320, 8, 881, 25697, 63, 3008, 63, 890, 63, 30832, 2968, 12780, 297, 283, 4567, 297, 283, 14738, 34, 297, 283, 6487, 297, 283, 39, 17587, 5156, 523, 4402, 14, 19170, 63, 3437, 275, 9638, 272, 710, 5982, 402, 4402, 17659, 370, 2195, 805, 14, 339, 27301, 1338, 787, 26, 7960, 4567, 12, 7633, 4567, 12, 10574, 4567, 12, 436, 6619, 4567, 14, 272, 408, 523, 1798, 14, 525, 63, 2094, 8, 489, 2850, 2593, 297, 489, 1720, 7782, 1918, 805, 6451, 2653, 12, 325, 14, 71, 14, 4233, 83, 367, 4233, 4696, 14, 283, 288, 283, 16986, 370, 5212, 4696, 8038, 489, 730, 29, 1273, 63, 11531, 14, 13283, 8, 2325, 63, 3556, 534, 17, 83, 1333, 421, 199, 318, 485, 2980, 3034, 6213, 8, 2087, 304, 523, 408, 1123, 2368, 3158, 89, 1399, 316, 3423, 1350, 1233, 370, 314, 1798, 1041, 523, 931, 63, 923, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 523, 931, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1365, 297, 489, 1720, 29, 18978, 14, 24023, 9, 523, 931, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1832, 13, 515, 297, 489, 1720, 7782, 2042, 370, 2257, 2082, 543, 1350, 1233, 14, 11105, 543, 283, 288, 2850, 8614, 13, 4623, 3305, 12459, 523, 931, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1365, 13, 515, 297, 489, 1720, 7782, 2042, 370, 2082, 543, 1350, 1233, 315, 8142, 5800, 283, 288, 283, 11334, 15529, 12, 1380, 1265, 4165, 642, 2725, 1553, 1365, 13, 633, 3305, 283, 288, 283, 374, 1415, 12459, 523, 1350, 63, 923, 275, 1798, 14, 525, 63, 25024, 63, 12730, 63, 923, 342, 523, 1350, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 4623, 297, 489, 1720, 29, 18978, 14, 24023, 12, 489, 730, 29, 1974, 14, 12584, 3325, 18736, 285, 794, 12311, 14014, 2844, 18111, 9, 523, 1350, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 8614, 13, 4623, 297, 489, 1720, 7782, 985, 402, 4475, 8142, 10533, 5315, 315, 1314, 1350, 1233, 911, 283, 288, 283, 1235, 5489, 14, 11105, 340, 282, 805, 365, 26181, 687, 282, 2257, 283, 288, 283, 3619, 8038, 489, 730, 29, 1974, 14, 12584, 3325, 18736, 285, 794, 12311, 14014, 2844, 18111, 9, 523, 1350, 63, 923, 14, 525, 63, 2094, 8, 489, 2850, 1365, 13, 633, 297, 489, 1720, 7782, 1918, 20503, 402, 282, 3982, 7611, 626, 15164, 314, 805, 3769, 283, 288, 283, 11060, 379, 14, 2779, 365, 402, 314, 1824, 26, 283, 288, 283, 2859, 921, 1365, 14, 23826, 14, 3098, 14, 957, 15, 80, 5321, 1715, 63, 344, 93, 4805, 288, 283, 82, 5321, 3417, 63, 354, 5995, 12, 2382, 1265, 1077, 23080, 2195, 666, 367, 283, 288, 283, 1459, 6272, 314, 1094, 590, 21873, 14, 2047, 883, 19413, 298, 82, 5321, 3417, 63, 354, 5995, 2, 283, 288, 283, 262, 1314, 1930, 314, 298, 885, 2, 7611, 365, 9394, 14, 283, 288, 283, 4395, 402, 314, 2633, 1553, 1365, 13, 5792, 12, 1553, 1365, 13, 4694, 12, 283, 288, 283, 269, 1553, 1365, 13, 1450, 883, 506, 1627, 370, 4165, 314, 1015, 315, 314, 283, 288, 283, 8421, 14, 982, 7179, 402, 3062, 787, 2741, 12, 314, 2061, 6974, 283, 288, 283, 504, 314, 2446, 5246, 365, 1202, 14, 982, 642, 2725, 365, 1627, 12, 283, 288, 283, 1589, 2725, 1553, 1365, 365, 1415, 436, 23369, 314, 931, 283, 288, 283, 17183, 314, 7611, 12459, 523, 1350, 63, 1023, 63, 923, 275, 1798, 14, 525, 63, 25024, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MauHernandez/cyclope
demo/cyclope_project/locale/dbgettext/articles/article/regiones-y-esquemas/text.py
2
6090
# -*- coding: utf-8 -*- gettext("""Es aquí donde utilizaremos las vistas asociadas que describimos en el punto anterior. Podemos decidir, por ejemplo, que en la región lateral izquierda se muestre una lista jerarquizada de las categorías pertenecientes a una colección, en la región superior se muestre un menú de navegación y en la barra lateral izquierda un listado de resúmenes de los contenidos de la categoría “Destacados”.""") # -*- coding: utf-8 -*- gettext("""!(left)/media/uploads/manual_cyclope_3/logica/5-elements.png(alt_text)!""") # -*- coding: utf-8 -*- gettext("""!(left)/media/uploads/manual_cyclope_3/logica/water-left.png(alt_text)!""") # -*- coding: utf-8 -*- gettext("""En Cyclope podemos utilizar diferentes esquemas para las diferentes secciones de nuestro sitio web, aunque el caso más común, que viene pre-configurado, es tener un esquema para la portada (o página de inicio) y otro para el resto del sitio web.""") # -*- coding: utf-8 -*- gettext("""h3. Qué son las Regiones""") # -*- coding: utf-8 -*- gettext("""Las Regiones están configuradas en un archivo llamado __init__.py de la carpeta donde se guardan los HTML de nuestro sitio. Nos permiten definir la cantidad de regiones que podrá tener nuestro sitio web. Cada Región se invoca dentro de los archivos HTML de nuestro Tema. En el caso de Neutrona Theme, la configuración de las regiones se ve así:""") # -*- coding: utf-8 -*- gettext("""bc. # *-- coding:utf-8 --*@""") # -*- coding: utf-8 -*- gettext("""\"\"Configuration for the Neutrona theme templates and regions.""") # -*- coding: utf-8 -*- gettext("""Attributes:""") # -*- coding: utf-8 -*- gettext("""verbose_name: name of theme to be displayed in the admin interface""") # -*- coding: utf-8 -*- gettext("""layout_templates: dictionary defining regions for the available templates""") # -*- coding: utf-8 -*- gettext("""\"\"\"""") # -*- coding: utf-8 -*- gettext("""from django.utils.translation import ugettext_lazy as _""") # -*- coding: utf-8 -*- gettext("""verbose_name = _('Neutrona')""") # -*- coding: utf-8 -*- gettext("""layout_templates = {""") # -*- coding: utf-8 -*- gettext("""'4_elements.html':""") # -*- coding: utf-8 -*- gettext("""{""") # -*- coding: utf-8 -*- gettext("""'verbose_name': _('4 Elements'),""") # -*- coding: utf-8 -*- gettext("""'regions' : {""") # -*- coding: utf-8 -*- gettext("""'air': _('air'),""") # -*- coding: utf-8 -*- gettext("""'water': _('water'),""") # -*- coding: utf-8 -*- gettext("""'before_fire': _('before fire'),""") # -*- coding: utf-8 -*- gettext("""'after_fire': _('after fire'),""") # -*- coding: utf-8 -*- gettext("""'earth': _('earth'),""") # -*- coding: utf-8 -*- gettext("""}""") # -*- coding: utf-8 -*- gettext("""},""") # -*- coding: utf-8 -*- gettext("""'5_elements.html':""") # -*- coding: utf-8 -*- gettext("""{""") # -*- coding: utf-8 -*- gettext("""'verbose_name': _('5 Elements'),""") # -*- coding: utf-8 -*- gettext("""'regions' : {""") # -*- coding: utf-8 -*- gettext("""'air': _('air'),""") # -*- coding: utf-8 -*- gettext("""'water': _('water'),""") # -*- coding: utf-8 -*- gettext("""'love': _('love'),""") # -*- coding: utf-8 -*- gettext("""'before_fire': _('before fire'),""") # -*- coding: utf-8 -*- gettext("""'after_fire': _('after fire'),""") # -*- coding: utf-8 -*- gettext("""'earth': _('earth'),""") # -*- coding: utf-8 -*- gettext("""}""") # -*- coding: utf-8 -*- gettext("""},""") # -*- coding: utf-8 -*- gettext("""'empty.html':""") # -*- coding: utf-8 -*- gettext("""{'verbose_name': _('Empty'),""") # -*- coding: utf-8 -*- gettext("""'regions': {}""") # -*- coding: utf-8 -*- gettext("""},""") # -*- coding: utf-8 -*- gettext("""'newsletter.html':""") # -*- coding: utf-8 -*- gettext("""{'verbose_name': _('Newsletter'),""") # -*- coding: utf-8 -*- gettext("""'regions' : {""") # -*- coding: utf-8 -*- gettext("""'header': _('header'),""") # -*- coding: utf-8 -*- gettext("""'before_content': _('before content'),""") # -*- coding: utf-8 -*- gettext("""'after_content': _('after content'),""") # -*- coding: utf-8 -*- gettext("""}""") # -*- coding: utf-8 -*- gettext("""},""") # -*- coding: utf-8 -*- gettext("""}""") # -*- coding: utf-8 -*- gettext("""Definir las Regiones de nuestro sitio en el documento de configuración __init_.py, nos permite poder definir por medio de la opción Esquemas, las vistas que queremos que se vean en cada región del sitio. Neutrona Theme, viene con regiones creadas por defecto que cubrirán la mayor cantidad de usos. Es por eso que te recomendamos no cambiar esta información salvo que realmente sepas lo que estás haciendo.""") # -*- coding: utf-8 -*- gettext("""h3. Qué son los Esquemas""") # -*- coding: utf-8 -*- gettext("""Los esquemas nos permiten generar “vistas” dentro de las regiones de nuestro sitio web, para cada tipo contenido creado, sean artículos, páginas, Bloques HTML, Colecciones, Categorías, Menús, Contactos, audios, videos, etc., etc.""") # -*- coding: utf-8 -*- gettext("""Por ejemplo podemos crear un Esquema que en la región “Agua” (Water) se muestre una lista jerarquizada de las categorías pertenecientes a una colección, en la región “Aire” (Air) se muestre un menú de navegación y en la región “Amor” (Love) se visualice un listado de resúmenes de los contenidos de la categoría “Destacados”.""") # -*- coding: utf-8 -*- gettext("""Por defecto, Neutrona Theme usa dos Esquemas preconfigurados: 5-Elements y 4-Elements. 5-Elements es el esquema para la portada del sitio, mientras que 4-Elements, está utilizado como Esquema interior, o sea, Esquema por defecto en \"Configuración Global(Cyclope 3: Configuración Global)\":/configuracion-global.""") # -*- coding: utf-8 -*- gettext("""En Neutrona Theme existen una base de datos en /demo/db/sandbox.db que podrás renombrar a site.db para tener todas las vistas posibles las regiones de cada Esquema: 4-Elements-SandBox y 5-Elements-SandBox.""") # -*- coding: utf-8 -*- gettext("""Diviértete mirando todas las posibilidades actuales y aprender a configurar tus propios Esquemas.""")
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 21658, 282, 392, 13676, 2793, 271, 7678, 19030, 1530, 16908, 23325, 373, 631, 305, 465, 3095, 350, 305, 17414, 7039, 4492, 16908, 655, 579, 299, 24087, 376, 17514, 14, 510, 380, 16908, 12985, 694, 12, 8706, 325, 74, 2109, 320, 12, 17414, 655, 1127, 1295, 73, 19228, 2945, 279, 284, 90, 783, 281, 983, 542, 333, 5291, 264, 32686, 769, 65, 1335, 281, 285, 392, 565, 10641, 477, 23325, 7737, 269, 13676, 305, 1126, 266, 685, 559, 287, 744, 282, 32686, 512, 10251, 27064, 12, 655, 1127, 1295, 73, 19228, 1613, 15499, 542, 333, 5291, 264, 625, 12953, 24602, 477, 302, 811, 5294, 27064, 612, 655, 1127, 4681, 345, 2945, 279, 284, 90, 783, 281, 983, 625, 769, 5129, 477, 522, 24602, 1410, 397, 477, 16406, 406, 724, 344, 736, 477, 1127, 7737, 269, 13676, 65, 27430, 251, 8004, 645, 20257, 8477, 252, 24887, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1, 8, 3039, 2447, 4603, 15, 21725, 15, 9285, 63, 1480, 1251, 321, 63, 19, 15, 15370, 65, 15, 21, 13, 5527, 14, 4524, 8, 4478, 63, 505, 9, 1, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1, 8, 3039, 2447, 4603, 15, 21725, 15, 9285, 63, 1480, 1251, 321, 63, 19, 15, 15370, 65, 15, 17217, 13, 3039, 14, 4524, 8, 4478, 63, 505, 9, 1, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1327, 18461, 1251, 321, 299, 380, 16908, 7678, 19030, 285, 487, 1485, 744, 9455, 544, 5892, 12665, 23325, 487, 1485, 744, 6513, 559, 4548, 477, 302, 5291, 293, 13877, 4538, 3330, 12, 282, 324, 544, 579, 14984, 79, 333, 11302, 83, 2414, 24602, 78, 12, 17414, 1321, 6349, 876, 13, 888, 300, 5129, 12, 9455, 16685, 281, 625, 9455, 544, 391, 12665, 1127, 1844, 10641, 334, 79, 299, 11302, 903, 65, 477, 315, 530, 2308, 9, 612, 312, 1374, 12665, 579, 4618, 79, 2150, 13877, 4538, 3330, 24887, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 72, 19, 14, 5843, 5741, 27970, 23325, 5044, 73, 4548, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 44, 305, 5044, 73, 4548, 4347, 11302, 78, 1101, 300, 350, 305, 655, 625, 3819, 1003, 79, 634, 17984, 5129, 636, 826, 4343, 647, 477, 1127, 9590, 321, 502, 2793, 271, 542, 24453, 290, 16406, 4163, 477, 302, 5291, 293, 13877, 4538, 14, 653, 736, 1126, 2664, 724, 347, 262, 723, 1127, 883, 5700, 350, 477, 1295, 73, 4548, 17414, 15329, 82, 11302, 16685, 281, 302, 5291, 293, 13877, 4538, 3330, 14, 445, 10641, 5044, 73, 19228, 542, 4572, 679, 65, 477, 343, 293, 477, 16406, 3819, 1003, 736, 4163, 477, 302, 5291, 293, 5773, 391, 14, 3447, 579, 14984, 79, 477, 30422, 65, 23978, 12, 1127, 1101, 12417, 27064, 477, 23325, 1295, 73, 4548, 542, 11199, 465, 13676, 26, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 3776, 14, 327, 627, 306, 2803, 26, 1624, 13, 24, 1553, 10, 32, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 13356, 2, 5688, 367, 314, 30422, 65, 8879, 7009, 436, 16150, 24887, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 5379, 26, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 3832, 63, 354, 26, 536, 402, 8879, 370, 506, 9080, 315, 314, 4628, 3217, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 4209, 63, 5876, 26, 2600, 12669, 16150, 367, 314, 2808, 7009, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 13356, 3212, 341, 7230, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 3832, 63, 354, 275, 4018, 20915, 65, 358, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 4209, 63, 5876, 275, 469, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 20, 63, 5527, 14, 1360, 356, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 91, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 3832, 63, 354, 356, 4018, 20, 6566, 83, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 11963, 7, 520, 469, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 8387, 356, 4018, 8387, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 17217, 356, 4018, 17217, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 5182, 63, 8935, 356, 4018, 5182, 8344, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 4399, 63, 8935, 356, 4018, 4399, 8344, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 2210, 273, 356, 4018, 2210, 273, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 93, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1386, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 21, 63, 5527, 14, 1360, 356, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 91, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 3832, 63, 354, 356, 4018, 21, 6566, 83, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 11963, 7, 520, 469, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 8387, 356, 4018, 8387, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 17217, 356, 4018, 17217, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 21658, 282, 392, 13676, 2793, 271, 7678, 19030, 1530, 16908, 23325, 373, 631, 305, 465, 3095, 350, 305, 17414, 7039, 4492, 16908, 655, 579, 299, 24087, 376, 17514, 14, 510, 380, 16908, 12985, 694, 12, 8706, 325, 74, 2109, 320, 12, 17414, 655, 1127, 1295, 73, 19228, 2945, 279, 284, 90, 783, 281, 983, 542, 333, 5291, 264, 32686, 769, 65, 1335, 281, 285, 392, 565, 10641, 477, 23325, 7737, 269, 13676, 305, 1126, 266, 685, 559, 287, 744, 282, 32686, 512, 10251, 27064, 12, 655, 1127, 1295, 73, 19228, 1613, 15499, 542, 333, 5291, 264, 625, 12953, 24602, 477, 302, 811, 5294, 27064, 612, 655, 1127, 4681, 345, 2945, 279, 284, 90, 783, 281, 983, 625, 769, 5129, 477, 522, 24602, 1410, 397, 477, 16406, 406, 724, 344, 736, 477, 1127, 7737, 269, 13676, 65, 27430, 251, 8004, 645, 20257, 8477, 252, 24887, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1, 8, 3039, 2447, 4603, 15, 21725, 15, 9285, 63, 1480, 1251, 321, 63, 19, 15, 15370, 65, 15, 21, 13, 5527, 14, 4524, 8, 4478, 63, 505, 9, 1, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1, 8, 3039, 2447, 4603, 15, 21725, 15, 9285, 63, 1480, 1251, 321, 63, 19, 15, 15370, 65, 15, 17217, 13, 3039, 14, 4524, 8, 4478, 63, 505, 9, 1, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1327, 18461, 1251, 321, 299, 380, 16908, 7678, 19030, 285, 487, 1485, 744, 9455, 544, 5892, 12665, 23325, 487, 1485, 744, 6513, 559, 4548, 477, 302, 5291, 293, 13877, 4538, 3330, 12, 282, 324, 544, 579, 14984, 79, 333, 11302, 83, 2414, 24602, 78, 12, 17414, 1321, 6349, 876, 13, 888, 300, 5129, 12, 9455, 16685, 281, 625, 9455, 544, 391, 12665, 1127, 1844, 10641, 334, 79, 299, 11302, 903, 65, 477, 315, 530, 2308, 9, 612, 312, 1374, 12665, 579, 4618, 79, 2150, 13877, 4538, 3330, 24887, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 72, 19, 14, 5843, 5741, 27970, 23325, 5044, 73, 4548, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 44, 305, 5044, 73, 4548, 4347, 11302, 78, 1101, 300, 350, 305, 655, 625, 3819, 1003, 79, 634, 17984, 5129, 636, 826, 4343, 647, 477, 1127, 9590, 321, 502, 2793, 271, 542, 24453, 290, 16406, 4163, 477, 302, 5291, 293, 13877, 4538, 14, 653, 736, 1126, 2664, 724, 347, 262, 723, 1127, 883, 5700, 350, 477, 1295, 73, 4548, 17414, 15329, 82, 11302, 16685, 281, 302, 5291, 293, 13877, 4538, 3330, 14, 445, 10641, 5044, 73, 19228, 542, 4572, 679, 65, 477, 343, 293, 477, 16406, 3819, 1003, 736, 4163, 477, 302, 5291, 293, 5773, 391, 14, 3447, 579, 14984, 79, 477, 30422, 65, 23978, 12, 1127, 1101, 12417, 27064, 477, 23325, 1295, 73, 4548, 542, 11199, 465, 13676, 26, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 3776, 14, 327, 627, 306, 2803, 26, 1624, 13, 24, 1553, 10, 32, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 13356, 2, 5688, 367, 314, 30422, 65, 8879, 7009, 436, 16150, 24887, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 5379, 26, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 3832, 63, 354, 26, 536, 402, 8879, 370, 506, 9080, 315, 314, 4628, 3217, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 4209, 63, 5876, 26, 2600, 12669, 16150, 367, 314, 2808, 7009, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 13356, 3212, 341, 7230, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 3832, 63, 354, 275, 4018, 20915, 65, 358, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 4209, 63, 5876, 275, 469, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 20, 63, 5527, 14, 1360, 356, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 91, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 3832, 63, 354, 356, 4018, 20, 6566, 83, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 11963, 7, 520, 469, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 8387, 356, 4018, 8387, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 17217, 356, 4018, 17217, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 5182, 63, 8935, 356, 4018, 5182, 8344, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 4399, 63, 8935, 356, 4018, 4399, 8344, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 2210, 273, 356, 4018, 2210, 273, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 93, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 1386, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 21, 63, 5527, 14, 1360, 356, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 91, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 3832, 63, 354, 356, 4018, 21, 6566, 83, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 11963, 7, 520, 469, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 8387, 356, 4018, 8387, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 7, 17217, 356, 4018, 17217, 659, 6141, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5152, 4852, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
neumerance/deploy
.venv/lib/python2.7/site-packages/babel/localedata.py
136
6247
# -*- coding: utf-8 -*- """ babel.localedata ~~~~~~~~~~~~~~~~ Low-level locale data access. :note: The `Locale` class, which uses this module under the hood, provides a more convenient interface for accessing the locale data. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. """ import os import threading from collections import MutableMapping from babel._compat import pickle _cache = {} _cache_lock = threading.RLock() _dirname = os.path.join(os.path.dirname(__file__), 'localedata') def exists(name): """Check whether locale data is available for the given locale. Ther return value is `True` if it exists, `False` otherwise. :param name: the locale identifier string """ if name in _cache: return True return os.path.exists(os.path.join(_dirname, '%s.dat' % name)) def locale_identifiers(): """Return a list of all locale identifiers for which locale data is available. .. versionadded:: 0.8.1 :return: a list of locale identifiers (strings) """ return [stem for stem, extension in [ os.path.splitext(filename) for filename in os.listdir(_dirname) ] if extension == '.dat' and stem != 'root'] def load(name, merge_inherited=True): """Load the locale data for the given locale. The locale data is a dictionary that contains much of the data defined by the Common Locale Data Repository (CLDR). This data is stored as a collection of pickle files inside the ``babel`` package. >>> d = load('en_US') >>> d['languages']['sv'] u'Swedish' Note that the results are cached, and subsequent requests for the same locale return the same dictionary: >>> d1 = load('en_US') >>> d2 = load('en_US') >>> d1 is d2 True :param name: the locale identifier string (or "root") :param merge_inherited: whether the inherited data should be merged into the data of the requested locale :raise `IOError`: if no locale data file is found for the given locale identifer, or one of the locales it inherits from """ _cache_lock.acquire() try: data = _cache.get(name) if not data: # Load inherited data if name == 'root' or not merge_inherited: data = {} else: parts = name.split('_') if len(parts) == 1: parent = 'root' else: parent = '_'.join(parts[:-1]) data = load(parent).copy() filename = os.path.join(_dirname, '%s.dat' % name) fileobj = open(filename, 'rb') try: if name != 'root' and merge_inherited: merge(data, pickle.load(fileobj)) else: data = pickle.load(fileobj) _cache[name] = data finally: fileobj.close() return data finally: _cache_lock.release() def merge(dict1, dict2): """Merge the data from `dict2` into the `dict1` dictionary, making copies of nested dictionaries. >>> d = {1: 'foo', 3: 'baz'} >>> merge(d, {1: 'Foo', 2: 'Bar'}) >>> items = d.items(); items.sort(); items [(1, 'Foo'), (2, 'Bar'), (3, 'baz')] :param dict1: the dictionary to merge into :param dict2: the dictionary containing the data that should be merged """ for key, val2 in dict2.items(): if val2 is not None: val1 = dict1.get(key) if isinstance(val2, dict): if val1 is None: val1 = {} if isinstance(val1, Alias): val1 = (val1, val2) elif isinstance(val1, tuple): alias, others = val1 others = others.copy() merge(others, val2) val1 = (alias, others) else: val1 = val1.copy() merge(val1, val2) else: val1 = val2 dict1[key] = val1 class Alias(object): """Representation of an alias in the locale data. An alias is a value that refers to some other part of the locale data, as specified by the `keys`. """ def __init__(self, keys): self.keys = tuple(keys) def __repr__(self): return '<%s %r>' % (type(self).__name__, self.keys) def resolve(self, data): """Resolve the alias based on the given data. This is done recursively, so if one alias resolves to a second alias, that second alias will also be resolved. :param data: the locale data :type data: `dict` """ base = data for key in self.keys: data = data[key] if isinstance(data, Alias): data = data.resolve(base) elif isinstance(data, tuple): alias, others = data data = alias.resolve(base) return data class LocaleDataDict(MutableMapping): """Dictionary wrapper that automatically resolves aliases to the actual values. """ def __init__(self, data, base=None): self._data = data if base is None: base = data self.base = base def __len__(self): return len(self._data) def __iter__(self): return iter(self._data) def __getitem__(self, key): orig = val = self._data[key] if isinstance(val, Alias): # resolve an alias val = val.resolve(self.base) if isinstance(val, tuple): # Merge a partial dict with an alias alias, others = val val = alias.resolve(self.base).copy() merge(val, others) if type(val) is dict: # Return a nested alias-resolving dict val = LocaleDataDict(val, base=self.base) if val is not orig: self._data[key] = val return val def __setitem__(self, key, value): self._data[key] = value def __delitem__(self, key): del self._data[key] def copy(self): return LocaleDataDict(self._data.copy(), base=self.base)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 29178, 14, 5508, 576, 272, 18294, 339, 21766, 13, 1896, 5867, 666, 2879, 14, 339, 520, 4610, 26, 710, 658, 20342, 64, 1021, 12, 1314, 4440, 642, 859, 1334, 314, 2636, 364, 12, 6571, 282, 1779, 1655, 22700, 3217, 367, 18549, 314, 5867, 666, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 699, 902, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 747, 199, 646, 5796, 199, 504, 5055, 492, 29396, 199, 199, 504, 29178, 423, 5819, 492, 5927, 421, 199, 63, 1637, 275, 1052, 199, 63, 1637, 63, 831, 275, 5796, 14, 30550, 342, 199, 63, 3475, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5508, 576, 358, 421, 199, 318, 3495, 8, 354, 304, 272, 408, 1799, 3775, 5867, 666, 365, 2808, 367, 314, 1627, 5867, 14, 221, 377, 2523, 272, 372, 574, 365, 658, 549, 64, 340, 652, 3495, 12, 658, 797, 64, 4257, 14, 339, 520, 635, 536, 26, 314, 5867, 5148, 1059, 272, 408, 272, 340, 536, 315, 485, 1637, 26, 267, 372, 715, 272, 372, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 1547, 3475, 12, 1543, 83, 14, 4616, 7, 450, 536, 430, 421, 199, 318, 5867, 63, 14227, 837, 272, 408, 1767, 282, 769, 402, 1006, 5867, 14154, 367, 1314, 5867, 666, 365, 272, 2808, 14, 339, 2508, 7445, 447, 378, 14, 24, 14, 17, 339, 520, 1107, 26, 282, 769, 402, 5867, 14154, 334, 5465, 9, 272, 408, 272, 372, 359, 18446, 367, 17408, 12, 3329, 315, 359, 267, 747, 14, 515, 14, 7973, 8, 1501, 9, 367, 1788, 315, 747, 14, 7374, 1547, 3475, 9, 272, 1622, 340, 3329, 508, 1987, 4616, 7, 436, 17408, 1137, 283, 1231, 418, 421, 199, 318, 2248, 8, 354, 12, 5389, 63, 17571, 29, 549, 304, 272, 408, 6200, 314, 5867, 666, 367, 314, 1627, 5867, 14, 339, 710, 5867, 666, 365, 282, 2600, 626, 3509, 8298, 402, 314, 666, 3247, 701, 272, 314, 13964, 28298, 3918, 24426, 334, 1981, 4564, 680, 961, 666, 365, 5489, 465, 282, 272, 3245, 402, 5927, 1584, 6272, 314, 1124, 66, 902, 1040, 2559, 14, 339, 1306, 366, 275, 2248, 360, 287, 63, 1668, 358, 272, 1306, 366, 459, 13209, 2545, 2772, 418, 272, 399, 7, 51, 1129, 29159, 7, 339, 3390, 626, 314, 2058, 787, 6328, 12, 436, 13372, 4145, 367, 314, 2011, 272, 5867, 372, 314, 2011, 2600, 26, 339, 1306, 366, 17, 275, 2248, 360, 287, 63, 1668, 358, 272, 1306, 366, 18, 275, 2248, 360, 287, 63, 1668, 358, 272, 1306, 366, 17, 365, 366, 18, 272, 715, 339, 520, 635, 536, 26, 314, 5867, 5148, 1059, 334, 269, 298, 1231, 531, 272, 520, 635, 5389, 63, 17571, 26, 3775, 314, 12623, 666, 1077, 506, 9545, 1901, 1169, 314, 666, 402, 314, 5839, 5867, 272, 520, 3730, 658, 13760, 8340, 340, 949, 5867, 666, 570, 365, 1911, 367, 314, 1627, 5867, 1993, 6120, 280, 2412, 12, 503, 1373, 402, 314, 24847, 652, 21592, 687, 272, 408, 272, 485, 1637, 63, 831, 14, 8174, 342, 272, 862, 26, 267, 666, 275, 485, 1637, 14, 362, 8, 354, 9, 267, 340, 440, 666, 26, 288, 327, 7190, 12623, 666, 288, 340, 536, 508, 283, 1231, 7, 503, 440, 5389, 63, 17571, 26, 355, 666, 275, 1052, 288, 587, 26, 355, 4184, 275, 536, 14, 1294, 26341, 355, 340, 822, 8, 4181, 9, 508, 413, 26, 490, 1676, 275, 283, 1231, 7, 355, 587, 26, 490, 1676, 275, 2513, 1370, 904, 8, 4181, 4439, 17, 566, 355, 666, 275, 2248, 8, 1708, 680, 1574, 342, 288, 1788, 275, 747, 14, 515, 14, 904, 1547, 3475, 12, 1543, 83, 14, 4616, 7, 450, 536, 9, 288, 11099, 275, 1551, 8, 1501, 12, 283, 4848, 358, 288, 862, 26, 355, 340, 536, 1137, 283, 1231, 7, 436, 5389, 63, 17571, 26, 490, 5389, 8, 576, 12, 5927, 14, 912, 8, 9234, 430, 355, 587, 26, 490, 666, 275, 5927, 14, 912, 8, 9234, 9, 355, 485, 1637, 59, 354, 61, 275, 666, 288, 3753, 26, 355, 11099, 14, 1600, 342, 267, 372, 666, 272, 3753, 26, 267, 485, 1637, 63, 831, 14, 3221, 342, 421, 199, 318, 5389, 8, 807, 17, 12, 1211, 18, 304, 272, 408, 11359, 314, 666, 687, 658, 807, 18, 64, 1901, 314, 658, 807, 17, 64, 2600, 12, 10663, 6866, 272, 402, 6032, 11196, 14, 339, 1306, 366, 275, 469, 17, 26, 283, 1421, 297, 650, 26, 283, 6185, 936, 272, 1306, 5389, 8, 68, 12, 469, 17, 26, 283, 5686, 297, 499, 26, 283, 5281, 3071, 272, 1306, 2974, 275, 366, 14, 1744, 7303, 2974, 14, 3191, 7303, 2974, 272, 3842, 17, 12, 283, 5686, 659, 334, 18, 12, 283, 5281, 659, 334, 19, 12, 283, 6185, 5440, 339, 520, 635, 1211, 17, 26, 314, 2600, 370, 5389, 1901, 272, 520, 635, 1211, 18, 26, 314, 2600, 3035, 314, 666, 626, 1077, 506, 9545, 272, 408, 272, 367, 790, 12, 1139, 18, 315, 1211, 18, 14, 1744, 837, 267, 340, 1139, 18, 365, 440, 488, 26, 288, 1139, 17, 275, 1211, 17, 14, 362, 8, 498, 9, 288, 340, 1228, 8, 637, 18, 12, 1211, 304, 355, 340, 1139, 17, 365, 488, 26, 490, 1139, 17, 275, 1052, 355, 340, 1228, 8, 637, 17, 12, 24777, 304, 490, 1139, 17, 275, 334, 637, 17, 12, 1139, 18, 9, 355, 916, 1228, 8, 637, 17, 12, 2008, 304, 490, 5162, 12, 11789, 275, 1139, 17, 490, 11789, 275, 11789, 14, 1574, 342, 490, 5389, 8, 21714, 12, 1139, 18, 9, 490, 1139, 17, 275, 334, 3620, 12, 11789, 9, 355, 587, 26, 490, 1139, 17, 275, 1139, 17, 14, 1574, 342, 490, 5389, 8, 637, 17, 12, 1139, 18, 9, 288, 587, 26, 355, 1139, 17, 275, 1139, 18, 288, 1211, 17, 59, 498, 61, 275, 1139, 17, 421, 199, 533, 24777, 8, 785, 304, 272, 408, 20609, 402, 376, 5162, 315, 314, 5867, 666, 14, 339, 1626, 5162, 365, 282, 574 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 29178, 14, 5508, 576, 272, 18294, 339, 21766, 13, 1896, 5867, 666, 2879, 14, 339, 520, 4610, 26, 710, 658, 20342, 64, 1021, 12, 1314, 4440, 642, 859, 1334, 314, 2636, 364, 12, 6571, 282, 1779, 1655, 22700, 3217, 367, 18549, 314, 5867, 666, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 699, 902, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 747, 199, 646, 5796, 199, 504, 5055, 492, 29396, 199, 199, 504, 29178, 423, 5819, 492, 5927, 421, 199, 63, 1637, 275, 1052, 199, 63, 1637, 63, 831, 275, 5796, 14, 30550, 342, 199, 63, 3475, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5508, 576, 358, 421, 199, 318, 3495, 8, 354, 304, 272, 408, 1799, 3775, 5867, 666, 365, 2808, 367, 314, 1627, 5867, 14, 221, 377, 2523, 272, 372, 574, 365, 658, 549, 64, 340, 652, 3495, 12, 658, 797, 64, 4257, 14, 339, 520, 635, 536, 26, 314, 5867, 5148, 1059, 272, 408, 272, 340, 536, 315, 485, 1637, 26, 267, 372, 715, 272, 372, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 1547, 3475, 12, 1543, 83, 14, 4616, 7, 450, 536, 430, 421, 199, 318, 5867, 63, 14227, 837, 272, 408, 1767, 282, 769, 402, 1006, 5867, 14154, 367, 1314, 5867, 666, 365, 272, 2808, 14, 339, 2508, 7445, 447, 378, 14, 24, 14, 17, 339, 520, 1107, 26, 282, 769, 402, 5867, 14154, 334, 5465, 9, 272, 408, 272, 372, 359, 18446, 367, 17408, 12, 3329, 315, 359, 267, 747, 14, 515, 14, 7973, 8, 1501, 9, 367, 1788, 315, 747, 14, 7374, 1547, 3475, 9, 272, 1622, 340, 3329, 508, 1987, 4616, 7, 436, 17408, 1137, 283, 1231, 418, 421, 199, 318, 2248, 8, 354, 12, 5389, 63, 17571, 29, 549, 304, 272, 408, 6200, 314, 5867, 666, 367, 314, 1627, 5867, 14, 339, 710, 5867, 666, 365, 282, 2600, 626, 3509, 8298, 402, 314, 666, 3247, 701, 272, 314, 13964, 28298, 3918, 24426, 334, 1981, 4564, 680, 961, 666, 365, 5489, 465, 282, 272, 3245, 402, 5927, 1584, 6272, 314, 1124, 66, 902, 1040, 2559, 14, 339, 1306, 366, 275, 2248, 360, 287, 63, 1668, 358, 272, 1306, 366, 459, 13209, 2545, 2772, 418, 272, 399, 7, 51, 1129, 29159, 7, 339, 3390, 626, 314, 2058, 787, 6328, 12, 436, 13372, 4145, 367, 314, 2011, 272, 5867, 372, 314, 2011, 2600, 26, 339, 1306, 366, 17, 275, 2248, 360, 287, 63, 1668, 358, 272, 1306, 366, 18, 275, 2248, 360, 287, 63, 1668, 358, 272, 1306, 366, 17, 365, 366, 18, 272, 715, 339, 520, 635, 536, 26, 314, 5867, 5148, 1059, 334, 269, 298, 1231, 531, 272, 520, 635, 5389, 63, 17571, 26, 3775, 314, 12623, 666, 1077, 506, 9545, 1901, 1169, 314, 666, 402, 314, 5839, 5867, 272, 520, 3730, 658, 13760, 8340, 340, 949, 5867, 666, 570, 365, 1911, 367, 314, 1627, 5867, 1993, 6120, 280, 2412, 12, 503, 1373, 402, 314, 24847, 652, 21592, 687, 272, 408, 272, 485, 1637, 63, 831, 14, 8174, 342, 272, 862, 26, 267, 666, 275, 485, 1637, 14, 362, 8, 354, 9, 267, 340, 440, 666, 26, 288, 327, 7190, 12623, 666, 288, 340, 536, 508, 283, 1231, 7, 503, 440, 5389, 63, 17571, 26, 355, 666, 275, 1052, 288, 587, 26, 355, 4184, 275, 536, 14, 1294, 26341, 355, 340, 822, 8, 4181, 9, 508, 413, 26, 490, 1676, 275, 283, 1231, 7, 355, 587, 26, 490, 1676, 275, 2513, 1370, 904, 8, 4181, 4439, 17, 566, 355, 666, 275, 2248, 8, 1708, 680, 1574, 342, 288, 1788, 275, 747, 14, 515, 14, 904, 1547, 3475, 12, 1543, 83, 14, 4616, 7, 450, 536, 9, 288, 11099, 275, 1551, 8, 1501, 12, 283, 4848, 358, 288, 862, 26, 355, 340, 536, 1137, 283, 1231, 7, 436, 5389, 63, 17571, 26, 490, 5389, 8, 576, 12, 5927, 14, 912, 8, 9234, 430, 355, 587, 26, 490, 666, 275, 5927, 14, 912, 8, 9234, 9, 355, 485, 1637, 59, 354, 61, 275, 666, 288, 3753, 26, 355, 11099, 14, 1600, 342, 267, 372, 666, 272, 3753, 26, 267, 485, 1637, 63, 831, 14, 3221, 342, 421, 199, 318, 5389, 8, 807, 17, 12, 1211, 18, 304, 272, 408, 11359, 314, 666, 687, 658, 807, 18, 64, 1901, 314, 658, 807, 17, 64, 2600, 12, 10663, 6866, 272, 402, 6032, 11196, 14, 339, 1306, 366, 275, 469, 17, 26, 283, 1421, 297, 650, 26, 283, 6185, 936, 272, 1306, 5389, 8, 68, 12, 469, 17, 26, 283, 5686, 297, 499, 26, 283, 5281, 3071, 272, 1306, 2974, 275, 366, 14, 1744, 7303, 2974, 14, 3191, 7303, 2974, 272, 3842, 17, 12, 283, 5686, 659, 334, 18, 12, 283, 5281, 659, 334, 19, 12, 283, 6185, 5440, 339, 520, 635, 1211, 17, 26, 314, 2600, 370, 5389, 1901, 272, 520, 635, 1211, 18, 26, 314, 2600, 3035, 314, 666, 626, 1077, 506, 9545, 272, 408, 272, 367, 790, 12, 1139, 18, 315, 1211, 18, 14, 1744, 837, 267, 340, 1139, 18, 365, 440, 488, 26, 288, 1139, 17, 275, 1211, 17, 14, 362, 8, 498, 9, 288, 340, 1228, 8, 637, 18, 12, 1211, 304, 355, 340, 1139, 17, 365, 488, 26, 490, 1139, 17, 275, 1052, 355, 340, 1228, 8, 637, 17, 12, 24777, 304, 490, 1139, 17, 275, 334, 637, 17, 12, 1139, 18, 9, 355, 916, 1228, 8, 637, 17, 12, 2008, 304, 490, 5162, 12, 11789, 275, 1139, 17, 490, 11789, 275, 11789, 14, 1574, 342, 490, 5389, 8, 21714, 12, 1139, 18, 9, 490, 1139, 17, 275, 334, 3620, 12, 11789, 9, 355, 587, 26, 490, 1139, 17, 275, 1139, 17, 14, 1574, 342, 490, 5389, 8, 637, 17, 12, 1139, 18, 9, 288, 587, 26, 355, 1139, 17, 275, 1139, 18, 288, 1211, 17, 59, 498, 61, 275, 1139, 17, 421, 199, 533, 24777, 8, 785, 304, 272, 408, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
chunjispring/environment
vim_setting/ftplugin/python/pyflakes/pyflakes/test/test_script.py
44
5335
""" Tests for L{pyflakes.scripts.pyflakes}. """ import sys from StringIO import StringIO from twisted.python.filepath import FilePath from twisted.trial.unittest import TestCase from pyflakes.scripts.pyflakes import checkPath def withStderrTo(stderr, f): """ Call C{f} with C{sys.stderr} redirected to C{stderr}. """ (outer, sys.stderr) = (sys.stderr, stderr) try: return f() finally: sys.stderr = outer class CheckTests(TestCase): """ Tests for L{check} and L{checkPath} which check a file for flakes. """ def test_missingTrailingNewline(self): """ Source which doesn't end with a newline shouldn't cause any exception to be raised nor an error indicator to be returned by L{check}. """ fName = self.mktemp() FilePath(fName).setContent("def foo():\n\tpass\n\t") self.assertFalse(checkPath(fName)) def test_checkPathNonExisting(self): """ L{checkPath} handles non-existing files. """ err = StringIO() count = withStderrTo(err, lambda: checkPath('extremo')) self.assertEquals(err.getvalue(), 'extremo: No such file or directory\n') self.assertEquals(count, 1) def test_multilineSyntaxError(self): """ Source which includes a syntax error which results in the raised L{SyntaxError.text} containing multiple lines of source are reported with only the last line of that source. """ source = """\ def foo(): ''' def bar(): pass def baz(): '''quux''' """ # Sanity check - SyntaxError.text should be multiple lines, if it # isn't, something this test was unprepared for has happened. def evaluate(source): exec source exc = self.assertRaises(SyntaxError, evaluate, source) self.assertTrue(exc.text.count('\n') > 1) sourcePath = FilePath(self.mktemp()) sourcePath.setContent(source) err = StringIO() count = withStderrTo(err, lambda: checkPath(sourcePath.path)) self.assertEqual(count, 1) self.assertEqual( err.getvalue(), """\ %s:8: invalid syntax '''quux''' ^ """ % (sourcePath.path,)) def test_eofSyntaxError(self): """ The error reported for source files which end prematurely causing a syntax error reflects the cause for the syntax error. """ source = "def foo(" sourcePath = FilePath(self.mktemp()) sourcePath.setContent(source) err = StringIO() count = withStderrTo(err, lambda: checkPath(sourcePath.path)) self.assertEqual(count, 1) self.assertEqual( err.getvalue(), """\ %s:1: unexpected EOF while parsing def foo( ^ """ % (sourcePath.path,)) def test_nonDefaultFollowsDefaultSyntaxError(self): """ Source which has a non-default argument following a default argument should include the line number of the syntax error. However these exceptions do not include an offset. """ source = """\ def foo(bar=baz, bax): pass """ sourcePath = FilePath(self.mktemp()) sourcePath.setContent(source) err = StringIO() count = withStderrTo(err, lambda: checkPath(sourcePath.path)) self.assertEqual(count, 1) self.assertEqual( err.getvalue(), """\ %s:1: non-default argument follows default argument def foo(bar=baz, bax): """ % (sourcePath.path,)) def test_nonKeywordAfterKeywordSyntaxError(self): """ Source which has a non-keyword argument after a keyword argument should include the line number of the syntax error. However these exceptions do not include an offset. """ source = """\ foo(bar=baz, bax) """ sourcePath = FilePath(self.mktemp()) sourcePath.setContent(source) err = StringIO() count = withStderrTo(err, lambda: checkPath(sourcePath.path)) self.assertEqual(count, 1) self.assertEqual( err.getvalue(), """\ %s:1: non-keyword arg after keyword arg foo(bar=baz, bax) """ % (sourcePath.path,)) def test_permissionDenied(self): """ If the a source file is not readable, this is reported on standard error. """ sourcePath = FilePath(self.mktemp()) sourcePath.setContent('') sourcePath.chmod(0) err = StringIO() count = withStderrTo(err, lambda: checkPath(sourcePath.path)) self.assertEquals(count, 1) self.assertEquals( err.getvalue(), "%s: Permission denied\n" % (sourcePath.path,)) def test_misencodedFile(self): """ If a source file contains bytes which cannot be decoded, this is reported on stderr. """ source = u"""\ # coding: ascii x = "\N{SNOWMAN}" """.encode('utf-8') sourcePath = FilePath(self.mktemp()) sourcePath.setContent(source) err = StringIO() count = withStderrTo(err, lambda: checkPath(sourcePath.path)) self.assertEquals(count, 1) self.assertEquals( err.getvalue(), "%s: problem decoding source\n" % (sourcePath.path,))
gpl-2.0
[ 199, 624, 199, 2925, 367, 491, 91, 647, 29677, 14, 6429, 14, 647, 29677, 5565, 199, 624, 199, 199, 646, 984, 199, 504, 5228, 492, 5228, 199, 199, 504, 7390, 14, 1548, 14, 7218, 492, 27961, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 199, 504, 1134, 29677, 14, 6429, 14, 647, 29677, 492, 1104, 2042, 199, 199, 318, 543, 933, 2303, 1378, 8, 3083, 12, 289, 304, 272, 408, 272, 6523, 445, 91, 70, 93, 543, 445, 91, 1274, 14, 3083, 93, 20884, 370, 445, 91, 3083, 5565, 272, 408, 272, 334, 7837, 12, 984, 14, 3083, 9, 275, 334, 1274, 14, 3083, 12, 4635, 9, 272, 862, 26, 267, 372, 289, 342, 272, 3753, 26, 267, 984, 14, 3083, 275, 6890, 4388, 199, 533, 2670, 2925, 8, 1746, 304, 272, 408, 272, 6496, 367, 491, 91, 1074, 93, 436, 491, 91, 1074, 2042, 93, 1314, 1104, 282, 570, 367, 17566, 9246, 14, 272, 408, 272, 347, 511, 63, 4752, 2437, 5662, 4665, 604, 8, 277, 304, 267, 408, 267, 5800, 1314, 3181, 1133, 1284, 543, 282, 8057, 9296, 1133, 7675, 1263, 267, 1919, 370, 506, 4915, 6590, 376, 1125, 16385, 370, 506, 2138, 701, 267, 491, 91, 1074, 5565, 267, 408, 267, 289, 985, 275, 291, 14, 22136, 342, 267, 27961, 8, 70, 985, 680, 28680, 480, 318, 3925, 837, 60, 78, 60, 32376, 60, 78, 60, 84, 531, 267, 291, 14, 3334, 8, 1074, 2042, 8, 70, 985, 430, 2378, 347, 511, 63, 1074, 2042, 6932, 23490, 8, 277, 304, 267, 408, 267, 491, 91, 1074, 2042, 93, 10022, 2222, 13, 5952, 1584, 14, 267, 408, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 360, 832, 21420, 1333, 267, 291, 14, 2947, 8, 1508, 14, 7150, 1062, 283, 832, 21420, 26, 3091, 4066, 570, 503, 2082, 60, 78, 358, 267, 291, 14, 2947, 8, 835, 12, 413, 9, 2378, 347, 511, 63, 21108, 9294, 8, 277, 304, 267, 408, 267, 5800, 1314, 6952, 282, 6302, 1125, 1314, 2058, 315, 314, 4915, 267, 491, 91, 9294, 14, 505, 93, 3035, 3663, 2385, 402, 1350, 787, 14581, 267, 543, 1454, 314, 2061, 1004, 402, 626, 1350, 14, 267, 408, 267, 1350, 275, 9638, 199, 318, 3925, 837, 272, 1449, 199, 199, 318, 4681, 837, 272, 986, 199, 199, 318, 15507, 837, 272, 1449, 32050, 2344, 199, 624, 398, 327, 22111, 1104, 446, 12053, 14, 505, 1077, 506, 3663, 2385, 12, 340, 652, 267, 327, 5712, 1133, 12, 6020, 642, 511, 1990, 625, 19260, 367, 965, 21056, 14, 267, 347, 9352, 8, 1365, 304, 288, 2146, 1350, 267, 3178, 275, 291, 14, 1855, 8, 9294, 12, 9352, 12, 1350, 9, 267, 291, 14, 1815, 8, 2804, 14, 505, 14, 835, 2258, 78, 358, 690, 413, 9, 398, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 398, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 24, 26, 3866, 6302, 272, 1449, 32050, 2344, 1779, 7167, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 511, 63, 11670, 9294, 8, 277, 304, 267, 408, 267, 710, 1125, 14581, 367, 1350, 1584, 1314, 1284, 876, 19925, 590, 25498, 282, 267, 6302, 1125, 16806, 83, 314, 7675, 367, 314, 6302, 1125, 14, 267, 408, 267, 1350, 275, 298, 318, 3925, 480, 267, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 267, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 17, 26, 10537, 9027, 1830, 6057, 199, 318, 3925, 8, 268, 7167, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 511, 63, 2865, 2698, 18696, 83, 2698, 9294, 8, 277, 304, 267, 408, 267, 5800, 1314, 965, 282, 2222, 13, 885, 1423, 2569, 282, 849, 1423, 267, 1077, 2387, 314, 1004, 1329, 402, 314, 6302, 1125, 14, 221, 9738, 3520, 267, 4967, 886, 440, 2387, 376, 3268, 14, 267, 408, 267, 1350, 275, 9638, 199, 318, 3925, 8, 1700, 29, 6185, 12, 330, 1219, 304, 272, 986, 199, 624, 267, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 267, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 17, 26, 2222, 13, 885, 1423, 11924, 849, 1423, 199, 318, 3925, 8, 1700, 29, 6185, 12, 330, 1219, 304, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 511, 63, 2865, 10650, 10881, 10650, 9294, 8, 277, 304, 267, 408, 267, 5800, 1314, 965, 282, 2222, 13, 6691, 1423, 2410, 282, 4252, 1423, 1077, 267, 2387, 314, 1004, 1329, 402, 314, 6302, 1125, 14, 221, 9738, 3520, 4967, 267, 886, 440, 2387, 376, 3268, 14, 267, 408, 267, 1350, 275, 9638, 199, 1421, 8, 1700, 29, 6185, 12, 330, 1219, 9, 199, 624, 267, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 267, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 17, 26, 2222, 13, 6691, 1680, 2410, 4252, 1680, 199, 1421, 8, 1700, 29, 6185, 12, 330, 1219, 9, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347 ]
[ 624, 199, 2925, 367, 491, 91, 647, 29677, 14, 6429, 14, 647, 29677, 5565, 199, 624, 199, 199, 646, 984, 199, 504, 5228, 492, 5228, 199, 199, 504, 7390, 14, 1548, 14, 7218, 492, 27961, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 199, 504, 1134, 29677, 14, 6429, 14, 647, 29677, 492, 1104, 2042, 199, 199, 318, 543, 933, 2303, 1378, 8, 3083, 12, 289, 304, 272, 408, 272, 6523, 445, 91, 70, 93, 543, 445, 91, 1274, 14, 3083, 93, 20884, 370, 445, 91, 3083, 5565, 272, 408, 272, 334, 7837, 12, 984, 14, 3083, 9, 275, 334, 1274, 14, 3083, 12, 4635, 9, 272, 862, 26, 267, 372, 289, 342, 272, 3753, 26, 267, 984, 14, 3083, 275, 6890, 4388, 199, 533, 2670, 2925, 8, 1746, 304, 272, 408, 272, 6496, 367, 491, 91, 1074, 93, 436, 491, 91, 1074, 2042, 93, 1314, 1104, 282, 570, 367, 17566, 9246, 14, 272, 408, 272, 347, 511, 63, 4752, 2437, 5662, 4665, 604, 8, 277, 304, 267, 408, 267, 5800, 1314, 3181, 1133, 1284, 543, 282, 8057, 9296, 1133, 7675, 1263, 267, 1919, 370, 506, 4915, 6590, 376, 1125, 16385, 370, 506, 2138, 701, 267, 491, 91, 1074, 5565, 267, 408, 267, 289, 985, 275, 291, 14, 22136, 342, 267, 27961, 8, 70, 985, 680, 28680, 480, 318, 3925, 837, 60, 78, 60, 32376, 60, 78, 60, 84, 531, 267, 291, 14, 3334, 8, 1074, 2042, 8, 70, 985, 430, 2378, 347, 511, 63, 1074, 2042, 6932, 23490, 8, 277, 304, 267, 408, 267, 491, 91, 1074, 2042, 93, 10022, 2222, 13, 5952, 1584, 14, 267, 408, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 360, 832, 21420, 1333, 267, 291, 14, 2947, 8, 1508, 14, 7150, 1062, 283, 832, 21420, 26, 3091, 4066, 570, 503, 2082, 60, 78, 358, 267, 291, 14, 2947, 8, 835, 12, 413, 9, 2378, 347, 511, 63, 21108, 9294, 8, 277, 304, 267, 408, 267, 5800, 1314, 6952, 282, 6302, 1125, 1314, 2058, 315, 314, 4915, 267, 491, 91, 9294, 14, 505, 93, 3035, 3663, 2385, 402, 1350, 787, 14581, 267, 543, 1454, 314, 2061, 1004, 402, 626, 1350, 14, 267, 408, 267, 1350, 275, 9638, 199, 318, 3925, 837, 272, 1449, 199, 199, 318, 4681, 837, 272, 986, 199, 199, 318, 15507, 837, 272, 1449, 32050, 2344, 199, 624, 398, 327, 22111, 1104, 446, 12053, 14, 505, 1077, 506, 3663, 2385, 12, 340, 652, 267, 327, 5712, 1133, 12, 6020, 642, 511, 1990, 625, 19260, 367, 965, 21056, 14, 267, 347, 9352, 8, 1365, 304, 288, 2146, 1350, 267, 3178, 275, 291, 14, 1855, 8, 9294, 12, 9352, 12, 1350, 9, 267, 291, 14, 1815, 8, 2804, 14, 505, 14, 835, 2258, 78, 358, 690, 413, 9, 398, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 398, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 24, 26, 3866, 6302, 272, 1449, 32050, 2344, 1779, 7167, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 511, 63, 11670, 9294, 8, 277, 304, 267, 408, 267, 710, 1125, 14581, 367, 1350, 1584, 1314, 1284, 876, 19925, 590, 25498, 282, 267, 6302, 1125, 16806, 83, 314, 7675, 367, 314, 6302, 1125, 14, 267, 408, 267, 1350, 275, 298, 318, 3925, 480, 267, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 267, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 17, 26, 10537, 9027, 1830, 6057, 199, 318, 3925, 8, 268, 7167, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 511, 63, 2865, 2698, 18696, 83, 2698, 9294, 8, 277, 304, 267, 408, 267, 5800, 1314, 965, 282, 2222, 13, 885, 1423, 2569, 282, 849, 1423, 267, 1077, 2387, 314, 1004, 1329, 402, 314, 6302, 1125, 14, 221, 9738, 3520, 267, 4967, 886, 440, 2387, 376, 3268, 14, 267, 408, 267, 1350, 275, 9638, 199, 318, 3925, 8, 1700, 29, 6185, 12, 330, 1219, 304, 272, 986, 199, 624, 267, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 267, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 17, 26, 2222, 13, 885, 1423, 11924, 849, 1423, 199, 318, 3925, 8, 1700, 29, 6185, 12, 330, 1219, 304, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 511, 63, 2865, 10650, 10881, 10650, 9294, 8, 277, 304, 267, 408, 267, 5800, 1314, 965, 282, 2222, 13, 6691, 1423, 2410, 282, 4252, 1423, 1077, 267, 2387, 314, 1004, 1329, 402, 314, 6302, 1125, 14, 221, 9738, 3520, 4967, 267, 886, 440, 2387, 376, 3268, 14, 267, 408, 267, 1350, 275, 9638, 199, 1421, 8, 1700, 29, 6185, 12, 330, 1219, 9, 199, 624, 267, 1350, 2042, 275, 27961, 8, 277, 14, 22136, 1012, 267, 1350, 2042, 14, 28680, 8, 1365, 9, 267, 2329, 275, 5228, 342, 267, 2338, 275, 543, 933, 2303, 1378, 8, 1508, 12, 2400, 26, 1104, 2042, 8, 1365, 2042, 14, 515, 430, 267, 291, 14, 629, 8, 835, 12, 413, 9, 267, 291, 14, 629, 8, 288, 2329, 14, 7150, 1062, 288, 9638, 199, 5, 83, 26, 17, 26, 2222, 13, 6691, 1680, 2410, 4252, 1680, 199, 1421, 8, 1700, 29, 6185, 12, 330, 1219, 9, 199, 624, 450, 334, 1365, 2042, 14, 515, 4641, 2378, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lacrazyboy/scrapy
tests/test_utils_log.py
140
3417
# -*- coding: utf-8 -*- from __future__ import print_function import sys import logging import unittest from testfixtures import LogCapture from twisted.python.failure import Failure from scrapy.utils.log import (failure_to_exc_info, TopLevelFormatter, LogCounterHandler, StreamLogger) from scrapy.utils.test import get_crawler class FailureToExcInfoTest(unittest.TestCase): def test_failure(self): try: 0/0 except ZeroDivisionError: exc_info = sys.exc_info() failure = Failure() self.assertTupleEqual(exc_info, failure_to_exc_info(failure)) def test_non_failure(self): self.assertIsNone(failure_to_exc_info('test')) class TopLevelFormatterTest(unittest.TestCase): def setUp(self): self.handler = LogCapture() self.handler.addFilter(TopLevelFormatter(['test'])) def test_top_level_logger(self): logger = logging.getLogger('test') with self.handler as l: logger.warning('test log msg') l.check(('test', 'WARNING', 'test log msg')) def test_children_logger(self): logger = logging.getLogger('test.test1') with self.handler as l: logger.warning('test log msg') l.check(('test', 'WARNING', 'test log msg')) def test_overlapping_name_logger(self): logger = logging.getLogger('test2') with self.handler as l: logger.warning('test log msg') l.check(('test2', 'WARNING', 'test log msg')) def test_different_name_logger(self): logger = logging.getLogger('different') with self.handler as l: logger.warning('test log msg') l.check(('different', 'WARNING', 'test log msg')) class LogCounterHandlerTest(unittest.TestCase): def setUp(self): self.logger = logging.getLogger('test') self.logger.setLevel(logging.NOTSET) self.logger.propagate = False self.crawler = get_crawler(settings_dict={'LOG_LEVEL': 'WARNING'}) self.handler = LogCounterHandler(self.crawler) self.logger.addHandler(self.handler) def tearDown(self): self.logger.propagate = True self.logger.removeHandler(self.handler) def test_init(self): self.assertIsNone(self.crawler.stats.get_value('log_count/DEBUG')) self.assertIsNone(self.crawler.stats.get_value('log_count/INFO')) self.assertIsNone(self.crawler.stats.get_value('log_count/WARNING')) self.assertIsNone(self.crawler.stats.get_value('log_count/ERROR')) self.assertIsNone(self.crawler.stats.get_value('log_count/CRITICAL')) def test_accepted_level(self): self.logger.error('test log msg') self.assertEqual(self.crawler.stats.get_value('log_count/ERROR'), 1) def test_filtered_out_level(self): self.logger.debug('test log msg') self.assertIsNone(self.crawler.stats.get_value('log_count/INFO')) class StreamLoggerTest(unittest.TestCase): def setUp(self): self.stdout = sys.stdout logger = logging.getLogger('test') logger.setLevel(logging.WARNING) sys.stdout = StreamLogger(logger, logging.ERROR) def tearDown(self): sys.stdout = self.stdout def test_redirect(self): with LogCapture() as l: print('test log msg') l.check(('test', 'ERROR', 'test log msg'))
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 2050, 199, 646, 2882, 199, 199, 504, 511, 8769, 492, 5297, 16640, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 199, 504, 18918, 14, 1208, 14, 793, 492, 334, 5328, 63, 475, 63, 2804, 63, 815, 12, 14132, 4670, 7772, 12, 2892, 5297, 11348, 2461, 12, 8271, 4455, 9, 199, 504, 18918, 14, 1208, 14, 396, 492, 664, 63, 23972, 421, 199, 533, 20367, 1378, 20702, 2354, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 5328, 8, 277, 304, 267, 862, 26, 288, 378, 15, 16, 267, 871, 25838, 26, 288, 3178, 63, 815, 275, 984, 14, 2804, 63, 815, 342, 288, 5988, 275, 20367, 342, 398, 291, 14, 479, 7075, 591, 8, 2804, 63, 815, 12, 5988, 63, 475, 63, 2804, 63, 815, 8, 5328, 430, 339, 347, 511, 63, 2865, 63, 5328, 8, 277, 304, 267, 291, 14, 7702, 8, 5328, 63, 475, 63, 2804, 63, 815, 360, 396, 1333, 421, 199, 533, 14132, 4670, 7772, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2232, 275, 5297, 16640, 342, 267, 291, 14, 2232, 14, 525, 4131, 8, 6105, 4670, 7772, 2941, 396, 5156, 339, 347, 511, 63, 2119, 63, 1896, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 396, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 396, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 339, 347, 511, 63, 3223, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 396, 14, 396, 17, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 396, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 339, 347, 511, 63, 31034, 63, 354, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 396, 18, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 396, 18, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 339, 347, 511, 63, 14020, 63, 354, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 14020, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 14020, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 421, 199, 533, 5297, 11348, 2461, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2921, 275, 2050, 14, 5572, 360, 396, 358, 267, 291, 14, 2921, 14, 13548, 8, 4806, 14, 4609, 3597, 9, 267, 291, 14, 2921, 14, 19432, 275, 756, 267, 291, 14, 23972, 275, 664, 63, 23972, 8, 1751, 63, 807, 3713, 4947, 63, 11817, 356, 283, 9171, 3071, 267, 291, 14, 2232, 275, 5297, 11348, 2461, 8, 277, 14, 23972, 9, 267, 291, 14, 2921, 14, 18826, 8, 277, 14, 2232, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 2921, 14, 19432, 275, 715, 267, 291, 14, 2921, 14, 2168, 2461, 8, 277, 14, 2232, 9, 339, 347, 511, 63, 826, 8, 277, 304, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 5287, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 4531, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 9171, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 3170, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 21539, 1333, 339, 347, 511, 63, 16121, 63, 1896, 8, 277, 304, 267, 291, 14, 2921, 14, 705, 360, 396, 943, 1499, 358, 267, 291, 14, 629, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 3170, 659, 413, 9, 339, 347, 511, 63, 11142, 63, 548, 63, 1896, 8, 277, 304, 267, 291, 14, 2921, 14, 1757, 360, 396, 943, 1499, 358, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 4531, 1333, 421, 199, 533, 8271, 4455, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2703, 275, 984, 14, 2703, 267, 2512, 275, 2050, 14, 5572, 360, 396, 358, 267, 2512, 14, 13548, 8, 4806, 14, 9171, 9, 267, 984, 14, 2703, 275, 8271, 4455, 8, 2921, 12, 2050, 14, 3170, 9, 339, 347, 6766, 8, 277, 304, 267, 984, 14, 2703, 275, 291, 14, 2703, 339, 347, 511, 63, 4876, 8, 277, 304, 267, 543, 5297, 16640, 342, 465, 634, 26, 288, 870, 360, 396, 943, 1499, 358, 267, 634, 14, 1074, 4725, 396, 297, 283, 3170, 297, 283, 396, 943, 1499, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 2050, 199, 646, 2882, 199, 199, 504, 511, 8769, 492, 5297, 16640, 199, 504, 7390, 14, 1548, 14, 5328, 492, 20367, 199, 199, 504, 18918, 14, 1208, 14, 793, 492, 334, 5328, 63, 475, 63, 2804, 63, 815, 12, 14132, 4670, 7772, 12, 2892, 5297, 11348, 2461, 12, 8271, 4455, 9, 199, 504, 18918, 14, 1208, 14, 396, 492, 664, 63, 23972, 421, 199, 533, 20367, 1378, 20702, 2354, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 5328, 8, 277, 304, 267, 862, 26, 288, 378, 15, 16, 267, 871, 25838, 26, 288, 3178, 63, 815, 275, 984, 14, 2804, 63, 815, 342, 288, 5988, 275, 20367, 342, 398, 291, 14, 479, 7075, 591, 8, 2804, 63, 815, 12, 5988, 63, 475, 63, 2804, 63, 815, 8, 5328, 430, 339, 347, 511, 63, 2865, 63, 5328, 8, 277, 304, 267, 291, 14, 7702, 8, 5328, 63, 475, 63, 2804, 63, 815, 360, 396, 1333, 421, 199, 533, 14132, 4670, 7772, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2232, 275, 5297, 16640, 342, 267, 291, 14, 2232, 14, 525, 4131, 8, 6105, 4670, 7772, 2941, 396, 5156, 339, 347, 511, 63, 2119, 63, 1896, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 396, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 396, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 339, 347, 511, 63, 3223, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 396, 14, 396, 17, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 396, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 339, 347, 511, 63, 31034, 63, 354, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 396, 18, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 396, 18, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 339, 347, 511, 63, 14020, 63, 354, 63, 2921, 8, 277, 304, 267, 2512, 275, 2050, 14, 5572, 360, 14020, 358, 267, 543, 291, 14, 2232, 465, 634, 26, 288, 2512, 14, 3764, 360, 396, 943, 1499, 358, 398, 634, 14, 1074, 4725, 14020, 297, 283, 9171, 297, 283, 396, 943, 1499, 1333, 421, 199, 533, 5297, 11348, 2461, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2921, 275, 2050, 14, 5572, 360, 396, 358, 267, 291, 14, 2921, 14, 13548, 8, 4806, 14, 4609, 3597, 9, 267, 291, 14, 2921, 14, 19432, 275, 756, 267, 291, 14, 23972, 275, 664, 63, 23972, 8, 1751, 63, 807, 3713, 4947, 63, 11817, 356, 283, 9171, 3071, 267, 291, 14, 2232, 275, 5297, 11348, 2461, 8, 277, 14, 23972, 9, 267, 291, 14, 2921, 14, 18826, 8, 277, 14, 2232, 9, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 2921, 14, 19432, 275, 715, 267, 291, 14, 2921, 14, 2168, 2461, 8, 277, 14, 2232, 9, 339, 347, 511, 63, 826, 8, 277, 304, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 5287, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 4531, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 9171, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 3170, 1333, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 21539, 1333, 339, 347, 511, 63, 16121, 63, 1896, 8, 277, 304, 267, 291, 14, 2921, 14, 705, 360, 396, 943, 1499, 358, 267, 291, 14, 629, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 3170, 659, 413, 9, 339, 347, 511, 63, 11142, 63, 548, 63, 1896, 8, 277, 304, 267, 291, 14, 2921, 14, 1757, 360, 396, 943, 1499, 358, 267, 291, 14, 7702, 8, 277, 14, 23972, 14, 3200, 14, 362, 63, 585, 360, 793, 63, 835, 15, 4531, 1333, 421, 199, 533, 8271, 4455, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2703, 275, 984, 14, 2703, 267, 2512, 275, 2050, 14, 5572, 360, 396, 358, 267, 2512, 14, 13548, 8, 4806, 14, 9171, 9, 267, 984, 14, 2703, 275, 8271, 4455, 8, 2921, 12, 2050, 14, 3170, 9, 339, 347, 6766, 8, 277, 304, 267, 984, 14, 2703, 275, 291, 14, 2703, 339, 347, 511, 63, 4876, 8, 277, 304, 267, 543, 5297, 16640, 342, 465, 634, 26, 288, 870, 360, 396, 943, 1499, 358, 267, 634, 14, 1074, 4725, 396, 297, 283, 3170, 297, 283, 396, 943, 1499, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
yury-s/v8-inspector
Source/chrome/tools/telemetry/telemetry/unittest_util/run_chromeos_tests.py
9
1946
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import logging import os from telemetry.core import util from telemetry.unittest_util import run_tests def RunTestsForChromeOS(browser_type, unit_tests, perf_tests): stream = _LoggingOutputStream() error_string = '' if unit_tests: logging.info('Running telemetry unit tests with browser_type "%s".' % browser_type) ret = _RunOneSetOfTests(browser_type, 'telemetry', unit_tests, stream) if ret: error_string += 'The unit tests failed.\n' if perf_tests: logging.info('Running telemetry perf tests with browser_type "%s".' % browser_type) ret = _RunOneSetOfTests(browser_type, 'perf', perf_tests, stream) if ret: error_string = 'The perf tests failed.\n' return error_string def _RunOneSetOfTests(browser_type, dir_name, tests, stream): top_level_dir = os.path.join(util.GetChromiumSrcDir(), 'tools', dir_name) args = ['--browser', browser_type, '--top-level-dir', top_level_dir, '--jobs', '1'] + tests return run_tests.RunTestsCommand.main(args, stream=stream) class _LoggingOutputStream(object): def __init__(self): self._buffer = [] def write(self, s): """Buffer a string write. Log it when we encounter a newline.""" if '\n' in s: segments = s.split('\n') segments[0] = ''.join(self._buffer + [segments[0]]) log_level = logging.getLogger().getEffectiveLevel() try: # TODO(dtu): We need this because of crbug.com/394571 logging.getLogger().setLevel(logging.INFO) for line in segments[:-1]: logging.info(line) finally: logging.getLogger().setLevel(log_level) self._buffer = [segments[-1]] else: self._buffer.append(s) def flush(self): # pylint: disable=W0612 pass
bsd-3-clause
[ 3, 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 17298, 14, 1018, 492, 4884, 199, 504, 17298, 14, 2796, 63, 1974, 492, 1255, 63, 2219, 421, 199, 318, 3378, 2925, 1858, 18083, 3100, 8, 5750, 63, 466, 12, 4137, 63, 2219, 12, 8582, 63, 2219, 304, 523, 2547, 275, 485, 14054, 10390, 342, 523, 1125, 63, 875, 275, 2125, 819, 340, 4137, 63, 2219, 26, 272, 2050, 14, 815, 360, 9602, 17298, 4137, 2295, 543, 7042, 63, 466, 2071, 83, 24217, 450, 355, 7042, 63, 466, 9, 272, 2203, 275, 485, 2540, 4395, 1084, 3466, 2925, 8, 5750, 63, 466, 12, 283, 15253, 10987, 297, 4137, 63, 2219, 12, 2547, 9, 272, 340, 2203, 26, 489, 1125, 63, 875, 847, 283, 1918, 4137, 2295, 3405, 3134, 78, 7, 819, 340, 8582, 63, 2219, 26, 272, 2050, 14, 815, 360, 9602, 17298, 8582, 2295, 543, 7042, 63, 466, 2071, 83, 24217, 450, 355, 7042, 63, 466, 9, 272, 2203, 275, 485, 2540, 4395, 1084, 3466, 2925, 8, 5750, 63, 466, 12, 283, 9452, 297, 8582, 63, 2219, 12, 2547, 9, 272, 340, 2203, 26, 489, 1125, 63, 875, 275, 283, 1918, 8582, 2295, 3405, 3134, 78, 7, 819, 372, 1125, 63, 875, 421, 199, 318, 485, 2540, 4395, 1084, 3466, 2925, 8, 5750, 63, 466, 12, 2935, 63, 354, 12, 2295, 12, 2547, 304, 523, 2746, 63, 1896, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1974, 14, 1002, 29381, 21261, 3567, 1062, 283, 2537, 297, 2935, 63, 354, 9, 523, 1249, 275, 14574, 5750, 297, 7042, 63, 466, 12, 881, 2850, 2119, 13, 1896, 13, 694, 297, 2746, 63, 1896, 63, 694, 12, 881, 2850, 6920, 297, 283, 17, 418, 435, 2295, 523, 372, 1255, 63, 2219, 14, 2540, 2925, 3110, 14, 973, 8, 589, 12, 2547, 29, 1745, 9, 421, 199, 533, 485, 14054, 10390, 8, 785, 304, 819, 347, 636, 826, 721, 277, 304, 272, 291, 423, 2738, 275, 942, 819, 347, 2218, 8, 277, 12, 308, 304, 272, 408, 3299, 282, 1059, 2218, 14, 5297, 652, 1380, 781, 655, 5337, 282, 8057, 1041, 272, 340, 1557, 78, 7, 315, 308, 26, 489, 11998, 275, 308, 14, 1294, 2258, 78, 358, 489, 11998, 59, 16, 61, 275, 6522, 904, 8, 277, 423, 2738, 435, 359, 13879, 59, 16, 3934, 489, 943, 63, 1896, 275, 2050, 14, 5572, 1252, 362, 30754, 4670, 342, 489, 862, 26, 221, 327, 3254, 8, 3583, 85, 304, 2136, 1929, 642, 2952, 402, 2467, 1266, 14, 957, 15, 13549, 17136, 267, 2050, 14, 5572, 1252, 13548, 8, 4806, 14, 4531, 9, 267, 367, 1004, 315, 11998, 4439, 17, 2189, 881, 2050, 14, 815, 8, 604, 9, 489, 3753, 26, 267, 2050, 14, 5572, 1252, 13548, 8, 793, 63, 1896, 9, 489, 291, 423, 2738, 275, 359, 13879, 1988, 17, 2677, 272, 587, 26, 489, 291, 423, 2738, 14, 740, 8, 83, 9, 819, 347, 8976, 8, 277, 304, 221, 327, 4287, 26, 3507, 29, 55, 1690, 713, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 17298, 14, 1018, 492, 4884, 199, 504, 17298, 14, 2796, 63, 1974, 492, 1255, 63, 2219, 421, 199, 318, 3378, 2925, 1858, 18083, 3100, 8, 5750, 63, 466, 12, 4137, 63, 2219, 12, 8582, 63, 2219, 304, 523, 2547, 275, 485, 14054, 10390, 342, 523, 1125, 63, 875, 275, 2125, 819, 340, 4137, 63, 2219, 26, 272, 2050, 14, 815, 360, 9602, 17298, 4137, 2295, 543, 7042, 63, 466, 2071, 83, 24217, 450, 355, 7042, 63, 466, 9, 272, 2203, 275, 485, 2540, 4395, 1084, 3466, 2925, 8, 5750, 63, 466, 12, 283, 15253, 10987, 297, 4137, 63, 2219, 12, 2547, 9, 272, 340, 2203, 26, 489, 1125, 63, 875, 847, 283, 1918, 4137, 2295, 3405, 3134, 78, 7, 819, 340, 8582, 63, 2219, 26, 272, 2050, 14, 815, 360, 9602, 17298, 8582, 2295, 543, 7042, 63, 466, 2071, 83, 24217, 450, 355, 7042, 63, 466, 9, 272, 2203, 275, 485, 2540, 4395, 1084, 3466, 2925, 8, 5750, 63, 466, 12, 283, 9452, 297, 8582, 63, 2219, 12, 2547, 9, 272, 340, 2203, 26, 489, 1125, 63, 875, 275, 283, 1918, 8582, 2295, 3405, 3134, 78, 7, 819, 372, 1125, 63, 875, 421, 199, 318, 485, 2540, 4395, 1084, 3466, 2925, 8, 5750, 63, 466, 12, 2935, 63, 354, 12, 2295, 12, 2547, 304, 523, 2746, 63, 1896, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1974, 14, 1002, 29381, 21261, 3567, 1062, 283, 2537, 297, 2935, 63, 354, 9, 523, 1249, 275, 14574, 5750, 297, 7042, 63, 466, 12, 881, 2850, 2119, 13, 1896, 13, 694, 297, 2746, 63, 1896, 63, 694, 12, 881, 2850, 6920, 297, 283, 17, 418, 435, 2295, 523, 372, 1255, 63, 2219, 14, 2540, 2925, 3110, 14, 973, 8, 589, 12, 2547, 29, 1745, 9, 421, 199, 533, 485, 14054, 10390, 8, 785, 304, 819, 347, 636, 826, 721, 277, 304, 272, 291, 423, 2738, 275, 942, 819, 347, 2218, 8, 277, 12, 308, 304, 272, 408, 3299, 282, 1059, 2218, 14, 5297, 652, 1380, 781, 655, 5337, 282, 8057, 1041, 272, 340, 1557, 78, 7, 315, 308, 26, 489, 11998, 275, 308, 14, 1294, 2258, 78, 358, 489, 11998, 59, 16, 61, 275, 6522, 904, 8, 277, 423, 2738, 435, 359, 13879, 59, 16, 3934, 489, 943, 63, 1896, 275, 2050, 14, 5572, 1252, 362, 30754, 4670, 342, 489, 862, 26, 221, 327, 3254, 8, 3583, 85, 304, 2136, 1929, 642, 2952, 402, 2467, 1266, 14, 957, 15, 13549, 17136, 267, 2050, 14, 5572, 1252, 13548, 8, 4806, 14, 4531, 9, 267, 367, 1004, 315, 11998, 4439, 17, 2189, 881, 2050, 14, 815, 8, 604, 9, 489, 3753, 26, 267, 2050, 14, 5572, 1252, 13548, 8, 793, 63, 1896, 9, 489, 291, 423, 2738, 275, 359, 13879, 1988, 17, 2677, 272, 587, 26, 489, 291, 423, 2738, 14, 740, 8, 83, 9, 819, 347, 8976, 8, 277, 304, 221, 327, 4287, 26, 3507, 29, 55, 1690, 713, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nolanliou/tensorflow
tensorflow/contrib/distributions/python/ops/mvn_tril.py
17
7524
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Multivariate Normal distribution classes.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib import linalg from tensorflow.contrib.distributions.python.ops import mvn_linear_operator as mvn_linop from tensorflow.python.framework import ops from tensorflow.python.ops.distributions import util as distribution_util __all__ = [ "MultivariateNormalTriL", ] class MultivariateNormalTriL( mvn_linop.MultivariateNormalLinearOperator): """The multivariate normal distribution on `R^k`. The Multivariate Normal distribution is defined over `R^k` and parameterized by a (batch of) length-`k` `loc` vector (aka "mu") and a (batch of) `k x k` `scale` matrix; `covariance = scale @ scale.T` where `@` denotes matrix-multiplication. #### Mathematical Details The probability density function (pdf) is, ```none pdf(x; loc, scale) = exp(-0.5 ||y||**2) / Z, y = inv(scale) @ (x - loc), Z = (2 pi)**(0.5 k) |det(scale)|, ``` where: * `loc` is a vector in `R^k`, * `scale` is a matrix in `R^{k x k}`, `covariance = scale @ scale.T`, * `Z` denotes the normalization constant, and, * `||y||**2` denotes the squared Euclidean norm of `y`. A (non-batch) `scale` matrix is: ```none scale = scale_tril ``` where `scale_tril` is lower-triangular `k x k` matrix with non-zero diagonal, i.e., `tf.diag_part(scale_tril) != 0`. Additional leading dimensions (if any) will index batches. The MultivariateNormal distribution is a member of the [location-scale family](https://en.wikipedia.org/wiki/Location-scale_family), i.e., it can be constructed as, ```none X ~ MultivariateNormal(loc=0, scale=1) # Identity scale, zero shift. Y = scale @ X + loc ``` Trainable (batch) lower-triangular matrices can be created with `tf.contrib.distributions.matrix_diag_transform()` and/or `tf.contrib.distributions.fill_triangular()` #### Examples ```python tfd = tf.contrib.distributions # Initialize a single 3-variate Gaussian. mu = [1., 2, 3] cov = [[ 0.36, 0.12, 0.06], [ 0.12, 0.29, -0.13], [ 0.06, -0.13, 0.26]] scale = tf.cholesky(cov) # ==> [[ 0.6, 0. , 0. ], # [ 0.2, 0.5, 0. ], # [ 0.1, -0.3, 0.4]]) mvn = tfd.MultivariateNormalTriL( loc=mu, scale_tril=scale) mvn.mean().eval() # ==> [1., 2, 3] # Covariance agrees with cholesky(cov) parameterization. mvn.covariance().eval() # ==> [[ 0.36, 0.12, 0.06], # [ 0.12, 0.29, -0.13], # [ 0.06, -0.13, 0.26]] # Compute the pdf of an observation in `R^3` ; return a scalar. mvn.prob([-1., 0, 1]).eval() # shape: [] # Initialize a 2-batch of 3-variate Gaussians. mu = [[1., 2, 3], [11, 22, 33]] # shape: [2, 3] tril = ... # shape: [2, 3, 3], lower triangular, non-zero diagonal. mvn = tfd.MultivariateNormalTriL( loc=mu, scale_tril=tril) # Compute the pdf of two `R^3` observations; return a length-2 vector. x = [[-0.9, 0, 0.1], [-10, 0, 9]] # shape: [2, 3] mvn.prob(x).eval() # shape: [2] # Instantiate a "learnable" MVN. dims = 4 with tf.variable_scope("model"): mvn = tfd.MultivariateNormalTriL( loc=tf.get_variable(shape=[dims], dtype=tf.float32, name="mu"), scale_tril=tfd.fill_triangular( tf.get_variable(shape=[dims * (dims + 1) / 2], dtype=tf.float32, name="chol_Sigma"))) ``` """ def __init__(self, loc=None, scale_tril=None, validate_args=False, allow_nan_stats=True, name="MultivariateNormalTriL"): """Construct Multivariate Normal distribution on `R^k`. The `batch_shape` is the broadcast shape between `loc` and `scale` arguments. The `event_shape` is given by last dimension of the matrix implied by `scale`. The last dimension of `loc` (if provided) must broadcast with this. Recall that `covariance = scale @ scale.T`. A (non-batch) `scale` matrix is: ```none scale = scale_tril ``` where `scale_tril` is lower-triangular `k x k` matrix with non-zero diagonal, i.e., `tf.diag_part(scale_tril) != 0`. Additional leading dimensions (if any) will index batches. Args: loc: Floating-point `Tensor`. If this is set to `None`, `loc` is implicitly `0`. When specified, may have shape `[B1, ..., Bb, k]` where `b >= 0` and `k` is the event size. scale_tril: Floating-point, lower-triangular `Tensor` with non-zero diagonal elements. `scale_tril` has shape `[B1, ..., Bb, k, k]` where `b >= 0` and `k` is the event size. validate_args: Python `bool`, default `False`. When `True` distribution parameters are checked for validity despite possibly degrading runtime performance. When `False` invalid inputs may silently render incorrect outputs. allow_nan_stats: Python `bool`, default `True`. When `True`, statistics (e.g., mean, mode, variance) use the value "`NaN`" to indicate the result is undefined. When `False`, an exception is raised if one or more of the statistic's batch members are undefined. name: Python `str` name prefixed to Ops created by this class. Raises: ValueError: if neither `loc` nor `scale_tril` are specified. """ parameters = locals() def _convert_to_tensor(x, name): return None if x is None else ops.convert_to_tensor(x, name=name) if loc is None and scale_tril is None: raise ValueError("Must specify one or both of `loc`, `scale_tril`.") with ops.name_scope(name): with ops.name_scope("init", values=[loc, scale_tril]): loc = _convert_to_tensor(loc, name="loc") scale_tril = _convert_to_tensor(scale_tril, name="scale_tril") if scale_tril is None: scale = linalg.LinearOperatorIdentity( num_rows=distribution_util.dimension_size(loc, -1), dtype=loc.dtype, is_self_adjoint=True, is_positive_definite=True, assert_proper_shapes=validate_args) else: # No need to validate that scale_tril is non-singular. # LinearOperatorLowerTriangular has an assert_non_singular # method that is called by the Bijector. scale = linalg.LinearOperatorLowerTriangular( scale_tril, is_non_singular=True, is_self_adjoint=False, is_positive_definite=False) super(MultivariateNormalTriL, self).__init__( loc=loc, scale=scale, validate_args=validate_args, allow_nan_stats=allow_nan_stats, name=name) self._parameters = parameters
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 3947, 13805, 11514, 4084, 3992, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 492, 16727, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 492, 333, 6002, 63, 6676, 63, 3856, 465, 333, 6002, 63, 472, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 492, 4884, 465, 4084, 63, 1974, 421, 199, 363, 452, 363, 275, 359, 272, 298, 3947, 13805, 6241, 6948, 44, 401, 199, 61, 421, 199, 533, 6879, 13805, 6241, 6948, 44, 8, 272, 333, 6002, 63, 472, 411, 14, 3947, 13805, 6241, 26463, 304, 523, 408, 1918, 32409, 3293, 4084, 641, 658, 50, 62, 75, 2313, 819, 710, 6879, 13805, 11514, 4084, 365, 3247, 1806, 658, 50, 62, 75, 64, 436, 29526, 523, 701, 282, 334, 2912, 402, 9, 2582, 13, 64, 75, 64, 658, 2102, 64, 5477, 334, 24685, 298, 6553, 531, 436, 282, 334, 2912, 402, 9, 658, 75, 671, 1022, 64, 523, 658, 3467, 64, 3634, 27, 658, 15024, 275, 4666, 768, 4666, 14, 52, 64, 2382, 658, 32, 64, 477, 5983, 523, 3634, 13, 8016, 1863, 14, 819, 14055, 16593, 28491, 15621, 819, 710, 12224, 13650, 805, 334, 5607, 9, 365, 12, 819, 10841, 3592, 523, 11249, 8, 88, 27, 4355, 12, 4666, 9, 275, 1437, 2801, 16, 14, 21, 12208, 89, 10644, 538, 18, 9, 1182, 3107, 12, 523, 612, 275, 4572, 8, 3467, 9, 768, 334, 88, 446, 4355, 395, 523, 3107, 275, 334, 18, 6682, 25288, 16, 14, 21, 1022, 9, 1204, 9886, 8, 3467, 8636, 12, 523, 10841, 819, 2382, 26, 819, 627, 658, 2102, 64, 365, 282, 5477, 315, 658, 50, 62, 75, 3559, 523, 627, 658, 3467, 64, 365, 282, 3634, 315, 658, 50, 11683, 75, 671, 1022, 93, 3559, 658, 15024, 275, 4666, 768, 4666, 14, 52, 3559, 523, 627, 658, 58, 64, 477, 5983, 314, 16973, 4413, 12, 436, 12, 523, 627, 658, 10644, 89, 10644, 538, 18, 64, 477, 5983, 314, 20478, 662, 24941, 6316, 402, 658, 89, 2313, 819, 437, 334, 2865, 13, 2912, 9, 658, 3467, 64, 3634, 365, 26, 819, 10841, 3592, 523, 4666, 275, 4666, 63, 32135, 523, 10841, 819, 2382, 658, 3467, 63, 32135, 64, 365, 5117, 13, 29663, 658, 75, 671, 1022, 64, 3634, 543, 2222, 13, 4262, 16788, 12, 523, 284, 14, 69, 2020, 658, 3249, 14, 6706, 63, 2064, 8, 3467, 63, 32135, 9, 1137, 378, 2313, 819, 10961, 9186, 7365, 334, 692, 1263, 9, 911, 1478, 19593, 14, 819, 710, 6879, 13805, 6241, 4084, 365, 282, 3653, 402, 314, 359, 1985, 13, 3467, 523, 9614, 8738, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 6592, 13, 3467, 63, 6606, 395, 284, 14, 69, 2020, 652, 883, 506, 523, 14701, 465, 12, 819, 10841, 3592, 523, 1323, 6146, 6879, 13805, 6241, 8, 2102, 29, 16, 12, 4666, 29, 17, 9, 257, 327, 22034, 4666, 12, 4697, 7706, 14, 523, 1488, 275, 4666, 768, 1323, 435, 4355, 523, 10841, 819, 16732, 461, 334, 2912, 9, 5117, 13, 29663, 12627, 883, 506, 2737, 543, 523, 658, 3249, 14, 2828, 14, 5613, 14, 3642, 63, 6706, 63, 4711, 11995, 436, 15, 269, 523, 658, 3249, 14, 2828, 14, 5613, 14, 4498, 63, 29663, 11995, 819, 14055, 6058, 819, 10841, 1548, 523, 307, 2592, 275, 2833, 14, 2828, 14, 5613, 819, 327, 11578, 282, 2849, 650, 13, 13805, 17131, 14, 523, 8504, 275, 359, 17, 2020, 499, 12, 650, 61, 523, 13786, 275, 3474, 378, 14, 1344, 12, 221, 378, 14, 713, 12, 221, 378, 14, 1690, 467, 268, 359, 378, 14, 713, 12, 221, 378, 14, 1398, 12, 446, 16, 14, 969, 467, 268, 359, 378, 14, 1690, 12, 446, 16, 14, 969, 12, 221, 378, 14, 1479, 2677, 523, 4666, 275, 2833, 14, 31369, 8, 8695, 9, 523, 327, 25375, 3474, 378, 14, 22, 12, 221, 378, 14, 2360, 221, 378, 14, 2156, 523, 327, 420, 359, 378, 14, 18, 12, 221, 378, 14, 21, 12, 221, 378, 14, 2156, 523, 327, 420, 359, 378, 14, 17, 12, 446, 16, 14, 19, 12, 221, 378, 14, 20, 3934, 523, 333, 6002, 275, 307, 2592, 14, 3947, 13805, 6241, 6948, 44, 8, 489, 4355, 29, 6553, 12, 489, 4666, 63, 32135, 29, 3467, 9, 819, 333, 6002, 14, 3670, 1252, 2579, 342, 523, 327, 25375, 359, 17, 2020, 499, 12, 650, 61, 819, 327, 1849, 6221, 1839, 5710, 543, 2468, 19881, 8, 8695, 9, 18117, 6236, 13362, 14, 523, 333, 6002, 14, 15024, 1252, 2579, 342, 523, 327, 25375, 3474, 378, 14, 1344, 12, 221, 378, 14, 713, 12, 221, 378, 14, 1690, 467, 523, 327, 420, 359, 378, 14, 713, 12, 221, 378, 14, 1398, 12, 446, 16, 14, 969, 467, 523, 327, 420, 359, 378, 14, 1690, 12, 446, 16, 14, 969, 12, 221, 378, 14, 1479, 2677, 819, 327, 8354, 314, 11249, 402, 376, 20038, 315, 658, 50, 62, 19, 64, 8700, 372, 282, 6917, 14, 523, 333, 6002, 14, 6101, 11468, 17, 2020, 378, 12, 413, 6575, 2579, 342, 221, 327, 2215, 26, 942, 819, 327, 11578, 282, 499, 13, 2912 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 3947, 13805, 11514, 4084, 3992, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 492, 16727, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 492, 333, 6002, 63, 6676, 63, 3856, 465, 333, 6002, 63, 472, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 492, 4884, 465, 4084, 63, 1974, 421, 199, 363, 452, 363, 275, 359, 272, 298, 3947, 13805, 6241, 6948, 44, 401, 199, 61, 421, 199, 533, 6879, 13805, 6241, 6948, 44, 8, 272, 333, 6002, 63, 472, 411, 14, 3947, 13805, 6241, 26463, 304, 523, 408, 1918, 32409, 3293, 4084, 641, 658, 50, 62, 75, 2313, 819, 710, 6879, 13805, 11514, 4084, 365, 3247, 1806, 658, 50, 62, 75, 64, 436, 29526, 523, 701, 282, 334, 2912, 402, 9, 2582, 13, 64, 75, 64, 658, 2102, 64, 5477, 334, 24685, 298, 6553, 531, 436, 282, 334, 2912, 402, 9, 658, 75, 671, 1022, 64, 523, 658, 3467, 64, 3634, 27, 658, 15024, 275, 4666, 768, 4666, 14, 52, 64, 2382, 658, 32, 64, 477, 5983, 523, 3634, 13, 8016, 1863, 14, 819, 14055, 16593, 28491, 15621, 819, 710, 12224, 13650, 805, 334, 5607, 9, 365, 12, 819, 10841, 3592, 523, 11249, 8, 88, 27, 4355, 12, 4666, 9, 275, 1437, 2801, 16, 14, 21, 12208, 89, 10644, 538, 18, 9, 1182, 3107, 12, 523, 612, 275, 4572, 8, 3467, 9, 768, 334, 88, 446, 4355, 395, 523, 3107, 275, 334, 18, 6682, 25288, 16, 14, 21, 1022, 9, 1204, 9886, 8, 3467, 8636, 12, 523, 10841, 819, 2382, 26, 819, 627, 658, 2102, 64, 365, 282, 5477, 315, 658, 50, 62, 75, 3559, 523, 627, 658, 3467, 64, 365, 282, 3634, 315, 658, 50, 11683, 75, 671, 1022, 93, 3559, 658, 15024, 275, 4666, 768, 4666, 14, 52, 3559, 523, 627, 658, 58, 64, 477, 5983, 314, 16973, 4413, 12, 436, 12, 523, 627, 658, 10644, 89, 10644, 538, 18, 64, 477, 5983, 314, 20478, 662, 24941, 6316, 402, 658, 89, 2313, 819, 437, 334, 2865, 13, 2912, 9, 658, 3467, 64, 3634, 365, 26, 819, 10841, 3592, 523, 4666, 275, 4666, 63, 32135, 523, 10841, 819, 2382, 658, 3467, 63, 32135, 64, 365, 5117, 13, 29663, 658, 75, 671, 1022, 64, 3634, 543, 2222, 13, 4262, 16788, 12, 523, 284, 14, 69, 2020, 658, 3249, 14, 6706, 63, 2064, 8, 3467, 63, 32135, 9, 1137, 378, 2313, 819, 10961, 9186, 7365, 334, 692, 1263, 9, 911, 1478, 19593, 14, 819, 710, 6879, 13805, 6241, 4084, 365, 282, 3653, 402, 314, 359, 1985, 13, 3467, 523, 9614, 8738, 2859, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 6592, 13, 3467, 63, 6606, 395, 284, 14, 69, 2020, 652, 883, 506, 523, 14701, 465, 12, 819, 10841, 3592, 523, 1323, 6146, 6879, 13805, 6241, 8, 2102, 29, 16, 12, 4666, 29, 17, 9, 257, 327, 22034, 4666, 12, 4697, 7706, 14, 523, 1488, 275, 4666, 768, 1323, 435, 4355, 523, 10841, 819, 16732, 461, 334, 2912, 9, 5117, 13, 29663, 12627, 883, 506, 2737, 543, 523, 658, 3249, 14, 2828, 14, 5613, 14, 3642, 63, 6706, 63, 4711, 11995, 436, 15, 269, 523, 658, 3249, 14, 2828, 14, 5613, 14, 4498, 63, 29663, 11995, 819, 14055, 6058, 819, 10841, 1548, 523, 307, 2592, 275, 2833, 14, 2828, 14, 5613, 819, 327, 11578, 282, 2849, 650, 13, 13805, 17131, 14, 523, 8504, 275, 359, 17, 2020, 499, 12, 650, 61, 523, 13786, 275, 3474, 378, 14, 1344, 12, 221, 378, 14, 713, 12, 221, 378, 14, 1690, 467, 268, 359, 378, 14, 713, 12, 221, 378, 14, 1398, 12, 446, 16, 14, 969, 467, 268, 359, 378, 14, 1690, 12, 446, 16, 14, 969, 12, 221, 378, 14, 1479, 2677, 523, 4666, 275, 2833, 14, 31369, 8, 8695, 9, 523, 327, 25375, 3474, 378, 14, 22, 12, 221, 378, 14, 2360, 221, 378, 14, 2156, 523, 327, 420, 359, 378, 14, 18, 12, 221, 378, 14, 21, 12, 221, 378, 14, 2156, 523, 327, 420, 359, 378, 14, 17, 12, 446, 16, 14, 19, 12, 221, 378, 14, 20, 3934, 523, 333, 6002, 275, 307, 2592, 14, 3947, 13805, 6241, 6948, 44, 8, 489, 4355, 29, 6553, 12, 489, 4666, 63, 32135, 29, 3467, 9, 819, 333, 6002, 14, 3670, 1252, 2579, 342, 523, 327, 25375, 359, 17, 2020, 499, 12, 650, 61, 819, 327, 1849, 6221, 1839, 5710, 543, 2468, 19881, 8, 8695, 9, 18117, 6236, 13362, 14, 523, 333, 6002, 14, 15024, 1252, 2579, 342, 523, 327, 25375, 3474, 378, 14, 1344, 12, 221, 378, 14, 713, 12, 221, 378, 14, 1690, 467, 523, 327, 420, 359, 378, 14, 713, 12, 221, 378, 14, 1398, 12, 446, 16, 14, 969, 467, 523, 327, 420, 359, 378, 14, 1690, 12, 446, 16, 14, 969, 12, 221, 378, 14, 1479, 2677, 819, 327, 8354, 314, 11249, 402, 376, 20038, 315, 658, 50, 62, 19, 64, 8700, 372, 282, 6917, 14, 523, 333, 6002, 14, 6101, 11468, 17, 2020, 378, 12, 413, 6575, 2579, 342, 221, 327, 2215, 26, 942, 819, 327, 11578, 282, 499, 13, 2912, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
hkchenhongyi/django
tests/auth_tests/models/custom_permissions.py
295
1433
""" The CustomPermissionsUser users email as the identifier, but uses the normal Django permissions model. This allows us to check that the PermissionsMixin includes everything that is needed to interact with the ModelBackend. """ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from django.contrib.auth.tests.custom_user import ( CustomUserManager, RemoveGroupsAndPermissions, ) from django.db import models from django.utils.encoding import python_2_unicode_compatible class CustomPermissionsUserManager(CustomUserManager): def create_superuser(self, email, password, date_of_birth): u = self.create_user(email, password=password, date_of_birth=date_of_birth) u.is_superuser = True u.save(using=self._db) return u with RemoveGroupsAndPermissions(): @python_2_unicode_compatible class CustomPermissionsUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField(verbose_name='email address', max_length=255, unique=True) date_of_birth = models.DateField() custom_objects = CustomPermissionsUserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['date_of_birth'] class Meta: app_label = 'auth' def get_full_name(self): return self.email def get_short_name(self): return self.email def __str__(self): return self.email
bsd-3-clause
[ 624, 199, 1918, 8388, 17004, 1899, 4390, 3031, 465, 314, 5148, 12, 1325, 4440, 314, 3293, 199, 9323, 3443, 1402, 14, 961, 6127, 2739, 370, 1104, 626, 314, 28260, 4256, 199, 9441, 8137, 626, 365, 4346, 370, 17232, 543, 314, 5822, 8447, 14, 199, 624, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 11836, 1563, 1899, 12, 28260, 4256, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 4229, 63, 751, 492, 334, 272, 8388, 1899, 2988, 12, 5852, 10177, 3325, 17004, 12, 199, 9, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 533, 8388, 17004, 1899, 2988, 8, 31482, 2988, 304, 272, 347, 1218, 63, 11434, 8, 277, 12, 3031, 12, 2505, 12, 1434, 63, 1618, 63, 10907, 304, 267, 399, 275, 291, 14, 981, 63, 751, 8, 2123, 12, 2505, 29, 2060, 12, 1434, 63, 1618, 63, 10907, 29, 602, 63, 1618, 63, 10907, 9, 267, 399, 14, 374, 63, 11434, 275, 715, 267, 399, 14, 2117, 8, 4941, 29, 277, 423, 697, 9, 267, 372, 399, 421, 199, 1045, 5852, 10177, 3325, 17004, 837, 272, 768, 1548, 63, 18, 63, 2975, 63, 6490, 272, 1021, 8388, 17004, 1899, 8, 8458, 1563, 1899, 12, 28260, 4256, 304, 267, 3031, 275, 1709, 14, 16577, 8, 3832, 63, 354, 534, 2123, 2287, 297, 1390, 63, 1267, 29, 2299, 12, 3747, 29, 549, 9, 267, 1434, 63, 1618, 63, 10907, 275, 1709, 14, 14071, 342, 398, 3537, 63, 1462, 275, 8388, 17004, 1899, 2988, 342, 398, 13044, 2339, 63, 8609, 275, 283, 2123, 7, 267, 25090, 63, 12767, 275, 788, 602, 63, 1618, 63, 10907, 418, 398, 1021, 6288, 26, 288, 1145, 63, 1302, 275, 283, 1178, 7, 398, 347, 664, 63, 2861, 63, 354, 8, 277, 304, 288, 372, 291, 14, 2123, 398, 347, 664, 63, 3612, 63, 354, 8, 277, 304, 288, 372, 291, 14, 2123, 398, 347, 636, 495, 721, 277, 304, 288, 372, 291, 14, 2123, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 1918, 8388, 17004, 1899, 4390, 3031, 465, 314, 5148, 12, 1325, 4440, 314, 3293, 199, 9323, 3443, 1402, 14, 961, 6127, 2739, 370, 1104, 626, 314, 28260, 4256, 199, 9441, 8137, 626, 365, 4346, 370, 17232, 543, 314, 5822, 8447, 14, 199, 624, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 11836, 1563, 1899, 12, 28260, 4256, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 4229, 63, 751, 492, 334, 272, 8388, 1899, 2988, 12, 5852, 10177, 3325, 17004, 12, 199, 9, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 533, 8388, 17004, 1899, 2988, 8, 31482, 2988, 304, 272, 347, 1218, 63, 11434, 8, 277, 12, 3031, 12, 2505, 12, 1434, 63, 1618, 63, 10907, 304, 267, 399, 275, 291, 14, 981, 63, 751, 8, 2123, 12, 2505, 29, 2060, 12, 1434, 63, 1618, 63, 10907, 29, 602, 63, 1618, 63, 10907, 9, 267, 399, 14, 374, 63, 11434, 275, 715, 267, 399, 14, 2117, 8, 4941, 29, 277, 423, 697, 9, 267, 372, 399, 421, 199, 1045, 5852, 10177, 3325, 17004, 837, 272, 768, 1548, 63, 18, 63, 2975, 63, 6490, 272, 1021, 8388, 17004, 1899, 8, 8458, 1563, 1899, 12, 28260, 4256, 304, 267, 3031, 275, 1709, 14, 16577, 8, 3832, 63, 354, 534, 2123, 2287, 297, 1390, 63, 1267, 29, 2299, 12, 3747, 29, 549, 9, 267, 1434, 63, 1618, 63, 10907, 275, 1709, 14, 14071, 342, 398, 3537, 63, 1462, 275, 8388, 17004, 1899, 2988, 342, 398, 13044, 2339, 63, 8609, 275, 283, 2123, 7, 267, 25090, 63, 12767, 275, 788, 602, 63, 1618, 63, 10907, 418, 398, 1021, 6288, 26, 288, 1145, 63, 1302, 275, 283, 1178, 7, 398, 347, 664, 63, 2861, 63, 354, 8, 277, 304, 288, 372, 291, 14, 2123, 398, 347, 664, 63, 3612, 63, 354, 8, 277, 304, 288, 372, 291, 14, 2123, 398, 347, 636, 495, 721, 277, 304, 288, 372, 291, 14, 2123, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jmartinm/inspire-next
inspire/modules/workflows/views/holdingpen_edit.py
2
4664
# -*- coding: utf-8 -*- # # This file is part of INSPIRE. # Copyright (C) 2015 CERN. # # INSPIRE is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # INSPIRE is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with INSPIRE; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """Blueprint for handling editing from Holding Pen.""" from invenio_deposit.helpers import make_record from six import text_type from flask import Blueprint, jsonify, request from flask_login import login_required from harvestingkit.html_utils import MathMLParser from invenio_base.decorators import wash_arguments from invenio_ext.principal import permission_required from invenio_workflows.acl import viewholdingpen from invenio_workflows.models import BibWorkflowObject from inspire.utils.helpers import get_model_from_obj blueprint = Blueprint( 'inspire_holdingpen', __name__, url_prefix="/admin/holdingpen", template_folder='../templates', static_folder="../static", ) # Helper methods for editing def get_attributes(objectid): """Returns the required attributes for record editing.""" editable_obj = BibWorkflowObject.query.get(objectid) model = get_model_from_obj(editable_obj) sip = model.get_latest_sip() metadata = sip.metadata return model, sip, metadata def save_changes(sip, model): """Saves the changes in the record.""" sip.package = make_record(sip.metadata) model.save() def json_success_message(attribute): return jsonify({ "category": "success", "message": "Edit on {0} was successful.".format(attribute) }) @blueprint.route('/edit_record_title', methods=['POST']) @login_required @permission_required(viewholdingpen.name) @wash_arguments({'value': (text_type, ""), 'objectid': (int, 0)}) def edit_record_title(value, objectid): """Entrypoint for editing title from detailed pages.""" model, sip, metadata = get_attributes(objectid) metadata["titles"][0] = {"title": MathMLParser.html_to_text(value)} save_changes(sip, model) return json_success_message('title') @blueprint.route('/edit_record_urls', methods=['POST']) @login_required @permission_required(viewholdingpen.name) @wash_arguments({'objectid': (text_type, "")}) def edit_record_urls(objectid): """Entrypoint for editing urls from detailed pages.""" model, sip, metadata = get_attributes(objectid) new_urls = request.values.getlist('urls[]') or [] # Get the new urls and format them, the way the object does new_urls_array = [] for url in new_urls: new_urls_array.append({'url': url}) metadata['url'] = new_urls_array save_changes(sip, model) return json_success_message('urls') @blueprint.route('/edit_record_subject', methods=['POST']) @login_required @permission_required(viewholdingpen.name) @wash_arguments({'objectid': (text_type, "")}) def edit_record_subject(objectid): """Entrypoint for editing subjects from detailed pages.""" model, sip, metadata = get_attributes(objectid) new_subjects_list = request.values.getlist('subjects[]') or [] subject_dict = [] subject_dict.extend(metadata.get("subject_terms")) old_subjects_list = [] for subj in subject_dict: old_subjects_list.append(subj["term"]) metadata["subject_terms"] = revised_subjects_list(old_subjects_list, new_subjects_list, subject_dict) save_changes(sip, model) return json_success_message('subjects') def revised_subjects_list(old, new, subject_dict): """Using sets, it determines which elements to remove and which to add when editing the subjects. """ to_remove = [str(x) for x in list(set(old) - set(new))] to_add = [str(x) for x in list(set(new) - set(old))] # Remove subjects subject_objects = [subj for subj in subject_dict if subj["term"] not in to_remove] # Add the new subjects for subj in to_add: subject_objects.append({ "term": subj, "scheme": "INSPIRE" }) return subject_objects
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1621, 20495, 907, 14, 199, 3, 1898, 334, 35, 9, 6900, 24354, 14, 199, 3, 199, 3, 1621, 20495, 907, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1621, 20495, 907, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 1621, 20495, 907, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 15617, 1361, 367, 7252, 20401, 687, 869, 13122, 510, 287, 1041, 199, 199, 504, 13640, 63, 271, 21759, 14, 7546, 492, 1852, 63, 3059, 199, 199, 504, 3816, 492, 1318, 63, 466, 199, 504, 7209, 492, 22447, 1361, 12, 23819, 12, 1056, 199, 504, 7209, 63, 2886, 492, 4676, 63, 2427, 199, 504, 12159, 13981, 316, 6065, 14, 1360, 63, 1208, 492, 21066, 1698, 2842, 199, 504, 13640, 63, 1095, 14, 11582, 492, 29050, 63, 4958, 199, 504, 13640, 63, 832, 14, 19200, 492, 4983, 63, 2427, 199, 504, 13640, 63, 25964, 14, 5853, 492, 2455, 72, 13122, 897, 199, 504, 13640, 63, 25964, 14, 992, 492, 21949, 17527, 1692, 199, 504, 315, 681, 3621, 14, 1208, 14, 7546, 492, 664, 63, 1238, 63, 504, 63, 1113, 421, 199, 15918, 275, 22447, 1361, 8, 272, 283, 262, 681, 3621, 63, 72, 13122, 897, 297, 272, 636, 354, 3108, 272, 1166, 63, 1861, 9555, 2113, 15, 72, 13122, 897, 401, 272, 1978, 63, 3741, 534, 5093, 5876, 297, 272, 2955, 63, 3741, 628, 5093, 1986, 401, 199, 9, 421, 199, 3, 11642, 3102, 367, 20401, 199, 318, 664, 63, 2987, 8, 1113, 31157, 304, 272, 408, 3407, 314, 1415, 3004, 367, 2777, 20401, 1041, 272, 14783, 63, 1113, 275, 21949, 17527, 1692, 14, 1131, 14, 362, 8, 1113, 31157, 9, 272, 1402, 275, 664, 63, 1238, 63, 504, 63, 1113, 8, 10820, 63, 1113, 9, 272, 25342, 275, 1402, 14, 362, 63, 7410, 63, 17839, 342, 272, 3341, 275, 25342, 14, 2343, 339, 372, 1402, 12, 25342, 12, 3341, 421, 199, 318, 3354, 63, 6627, 8, 17839, 12, 1402, 304, 272, 408, 51, 7047, 314, 4493, 315, 314, 2777, 1041, 272, 25342, 14, 2491, 275, 1852, 63, 3059, 8, 17839, 14, 2343, 9, 272, 1402, 14, 2117, 342, 421, 199, 318, 2022, 63, 3742, 63, 1188, 8, 3215, 304, 272, 372, 23819, 2561, 267, 298, 3710, 582, 298, 3742, 401, 267, 298, 1188, 582, 298, 4685, 641, 469, 16, 93, 1990, 9512, 15848, 908, 8, 3215, 9, 272, 3828, 421, 199, 32, 15918, 14, 4449, 2336, 3773, 63, 3059, 63, 1213, 297, 3102, 2968, 4030, 1105, 199, 32, 2886, 63, 2427, 199, 32, 5693, 63, 2427, 8, 1345, 72, 13122, 897, 14, 354, 9, 199, 32, 87, 1119, 63, 4958, 3252, 585, 356, 334, 505, 63, 466, 12, 16241, 326, 283, 1113, 31157, 356, 334, 442, 12, 378, 11466, 199, 318, 5283, 63, 3059, 63, 1213, 8, 585, 12, 1559, 31157, 304, 272, 408, 3900, 1403, 367, 20401, 2538, 687, 16212, 6497, 1041, 272, 1402, 12, 25342, 12, 3341, 275, 664, 63, 2987, 8, 1113, 31157, 9, 339, 3341, 905, 8916, 9210, 16, 61, 275, 2420, 1213, 582, 21066, 1698, 2842, 14, 1360, 63, 475, 63, 505, 8, 585, 6769, 272, 3354, 63, 6627, 8, 17839, 12, 1402, 9, 272, 372, 2022, 63, 3742, 63, 1188, 360, 1213, 358, 421, 199, 32, 15918, 14, 4449, 2336, 3773, 63, 3059, 63, 3603, 297, 3102, 2968, 4030, 1105, 199, 32, 2886, 63, 2427, 199, 32, 5693, 63, 2427, 8, 1345, 72, 13122, 897, 14, 354, 9, 199, 32, 87, 1119, 63, 4958, 3252, 1113, 31157, 356, 334, 505, 63, 466, 12, 6899, 1552, 199, 318, 5283, 63, 3059, 63, 3603, 8, 1113, 31157, 304, 272, 408, 3900, 1403, 367, 20401, 8187, 687, 16212, 6497, 1041, 272, 1402, 12, 25342, 12, 3341, 275, 664, 63, 2987, 8, 1113, 31157, 9, 272, 892, 63, 3603, 275, 1056, 14, 1459, 14, 21343, 360, 3603, 8607, 358, 503, 942, 339, 327, 2372, 314, 892, 8187, 436, 1475, 3062, 12, 314, 4340, 314, 909, 1630, 272, 892, 63, 3603, 63, 1144, 275, 942, 272, 367, 1166, 315, 892, 63, 3603, 26, 267, 892, 63, 3603, 63, 1144, 14, 740, 3252, 633, 356, 1166, 1552, 339, 3341, 459, 633, 418, 275, 892, 63, 3603, 63, 1144, 272, 3354, 63, 6627, 8, 17839, 12, 1402, 9, 272, 372, 2022, 63, 3742, 63, 1188, 360, 3603, 358, 421, 199, 32, 15918, 14, 4449, 2336, 3773, 63, 3059, 63, 5875, 297, 3102, 2968, 4030, 1105, 199, 32, 2886, 63, 2427, 199, 32, 5693, 63, 2427, 8, 1345, 72, 13122, 897, 14, 354, 9, 199, 32, 87, 1119, 63, 4958, 3252, 1113, 31157, 356, 334, 505, 63, 466, 12, 6899, 1552, 199, 318, 5283, 63, 3059, 63, 5875, 8, 1113, 31157, 304, 272, 408, 3900, 1403, 367, 20401, 32446, 687, 16212, 6497, 1041, 272, 1402, 12, 25342, 12, 3341, 275, 664, 63, 2987, 8, 1113, 31157, 9, 272, 892, 63, 25660, 63, 513, 275, 1056, 14, 1459, 14, 21343, 360, 25660, 8607, 358, 503, 942, 339, 5420, 63, 807, 275, 942, 272, 5420, 63, 807, 14, 2880, 8, 2343, 14, 362, 480, 5875, 63, 9187, 2237, 339, 2269, 63, 25660, 63, 513, 275, 942, 272, 367, 1007, 74, 315, 5420, 63, 807, 26, 267, 2269, 63, 25660, 63, 513, 14, 740, 8, 954, 74, 905, 5125, 3135, 339, 3341, 905, 5875, 63, 9187, 937, 275, 295 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1621, 20495, 907, 14, 199, 3, 1898, 334, 35, 9, 6900, 24354, 14, 199, 3, 199, 3, 1621, 20495, 907, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1621, 20495, 907, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 1621, 20495, 907, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 15617, 1361, 367, 7252, 20401, 687, 869, 13122, 510, 287, 1041, 199, 199, 504, 13640, 63, 271, 21759, 14, 7546, 492, 1852, 63, 3059, 199, 199, 504, 3816, 492, 1318, 63, 466, 199, 504, 7209, 492, 22447, 1361, 12, 23819, 12, 1056, 199, 504, 7209, 63, 2886, 492, 4676, 63, 2427, 199, 504, 12159, 13981, 316, 6065, 14, 1360, 63, 1208, 492, 21066, 1698, 2842, 199, 504, 13640, 63, 1095, 14, 11582, 492, 29050, 63, 4958, 199, 504, 13640, 63, 832, 14, 19200, 492, 4983, 63, 2427, 199, 504, 13640, 63, 25964, 14, 5853, 492, 2455, 72, 13122, 897, 199, 504, 13640, 63, 25964, 14, 992, 492, 21949, 17527, 1692, 199, 504, 315, 681, 3621, 14, 1208, 14, 7546, 492, 664, 63, 1238, 63, 504, 63, 1113, 421, 199, 15918, 275, 22447, 1361, 8, 272, 283, 262, 681, 3621, 63, 72, 13122, 897, 297, 272, 636, 354, 3108, 272, 1166, 63, 1861, 9555, 2113, 15, 72, 13122, 897, 401, 272, 1978, 63, 3741, 534, 5093, 5876, 297, 272, 2955, 63, 3741, 628, 5093, 1986, 401, 199, 9, 421, 199, 3, 11642, 3102, 367, 20401, 199, 318, 664, 63, 2987, 8, 1113, 31157, 304, 272, 408, 3407, 314, 1415, 3004, 367, 2777, 20401, 1041, 272, 14783, 63, 1113, 275, 21949, 17527, 1692, 14, 1131, 14, 362, 8, 1113, 31157, 9, 272, 1402, 275, 664, 63, 1238, 63, 504, 63, 1113, 8, 10820, 63, 1113, 9, 272, 25342, 275, 1402, 14, 362, 63, 7410, 63, 17839, 342, 272, 3341, 275, 25342, 14, 2343, 339, 372, 1402, 12, 25342, 12, 3341, 421, 199, 318, 3354, 63, 6627, 8, 17839, 12, 1402, 304, 272, 408, 51, 7047, 314, 4493, 315, 314, 2777, 1041, 272, 25342, 14, 2491, 275, 1852, 63, 3059, 8, 17839, 14, 2343, 9, 272, 1402, 14, 2117, 342, 421, 199, 318, 2022, 63, 3742, 63, 1188, 8, 3215, 304, 272, 372, 23819, 2561, 267, 298, 3710, 582, 298, 3742, 401, 267, 298, 1188, 582, 298, 4685, 641, 469, 16, 93, 1990, 9512, 15848, 908, 8, 3215, 9, 272, 3828, 421, 199, 32, 15918, 14, 4449, 2336, 3773, 63, 3059, 63, 1213, 297, 3102, 2968, 4030, 1105, 199, 32, 2886, 63, 2427, 199, 32, 5693, 63, 2427, 8, 1345, 72, 13122, 897, 14, 354, 9, 199, 32, 87, 1119, 63, 4958, 3252, 585, 356, 334, 505, 63, 466, 12, 16241, 326, 283, 1113, 31157, 356, 334, 442, 12, 378, 11466, 199, 318, 5283, 63, 3059, 63, 1213, 8, 585, 12, 1559, 31157, 304, 272, 408, 3900, 1403, 367, 20401, 2538, 687, 16212, 6497, 1041, 272, 1402, 12, 25342, 12, 3341, 275, 664, 63, 2987, 8, 1113, 31157, 9, 339, 3341, 905, 8916, 9210, 16, 61, 275, 2420, 1213, 582, 21066, 1698, 2842, 14, 1360, 63, 475, 63, 505, 8, 585, 6769, 272, 3354, 63, 6627, 8, 17839, 12, 1402, 9, 272, 372, 2022, 63, 3742, 63, 1188, 360, 1213, 358, 421, 199, 32, 15918, 14, 4449, 2336, 3773, 63, 3059, 63, 3603, 297, 3102, 2968, 4030, 1105, 199, 32, 2886, 63, 2427, 199, 32, 5693, 63, 2427, 8, 1345, 72, 13122, 897, 14, 354, 9, 199, 32, 87, 1119, 63, 4958, 3252, 1113, 31157, 356, 334, 505, 63, 466, 12, 6899, 1552, 199, 318, 5283, 63, 3059, 63, 3603, 8, 1113, 31157, 304, 272, 408, 3900, 1403, 367, 20401, 8187, 687, 16212, 6497, 1041, 272, 1402, 12, 25342, 12, 3341, 275, 664, 63, 2987, 8, 1113, 31157, 9, 272, 892, 63, 3603, 275, 1056, 14, 1459, 14, 21343, 360, 3603, 8607, 358, 503, 942, 339, 327, 2372, 314, 892, 8187, 436, 1475, 3062, 12, 314, 4340, 314, 909, 1630, 272, 892, 63, 3603, 63, 1144, 275, 942, 272, 367, 1166, 315, 892, 63, 3603, 26, 267, 892, 63, 3603, 63, 1144, 14, 740, 3252, 633, 356, 1166, 1552, 339, 3341, 459, 633, 418, 275, 892, 63, 3603, 63, 1144, 272, 3354, 63, 6627, 8, 17839, 12, 1402, 9, 272, 372, 2022, 63, 3742, 63, 1188, 360, 3603, 358, 421, 199, 32, 15918, 14, 4449, 2336, 3773, 63, 3059, 63, 5875, 297, 3102, 2968, 4030, 1105, 199, 32, 2886, 63, 2427, 199, 32, 5693, 63, 2427, 8, 1345, 72, 13122, 897, 14, 354, 9, 199, 32, 87, 1119, 63, 4958, 3252, 1113, 31157, 356, 334, 505, 63, 466, 12, 6899, 1552, 199, 318, 5283, 63, 3059, 63, 5875, 8, 1113, 31157, 304, 272, 408, 3900, 1403, 367, 20401, 32446, 687, 16212, 6497, 1041, 272, 1402, 12, 25342, 12, 3341, 275, 664, 63, 2987, 8, 1113, 31157, 9, 272, 892, 63, 25660, 63, 513, 275, 1056, 14, 1459, 14, 21343, 360, 25660, 8607, 358, 503, 942, 339, 5420, 63, 807, 275, 942, 272, 5420, 63, 807, 14, 2880, 8, 2343, 14, 362, 480, 5875, 63, 9187, 2237, 339, 2269, 63, 25660, 63, 513, 275, 942, 272, 367, 1007, 74, 315, 5420, 63, 807, 26, 267, 2269, 63, 25660, 63, 513, 14, 740, 8, 954, 74, 905, 5125, 3135, 339, 3341, 905, 5875, 63, 9187, 937, 275, 295, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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db import models class RedditUser(models.Model): user = models.OneToOneField(User) first_name = models.CharField(max_length=35, null=True, default=None, blank=True) last_name = models.CharField(max_length=35, null=True, default=None, blank=True) email = models.EmailField(null=True, blank=True, default=None) about_text = models.TextField(blank=True, null=True, max_length=500, default=None) about_html = models.TextField(blank=True, null=True, default=None) gravatar_hash = models.CharField(max_length=32, null=True, blank=True, default=None) display_picture = models.NullBooleanField(default=False) homepage = models.URLField(null=True, blank=True, default=None) twitter = models.CharField(null=True, blank=True, max_length=15, default=None) github = models.CharField(null=True, blank=True, max_length=39, default=None) comment_karma = models.IntegerField(default=0) link_karma = models.IntegerField(default=0) def update_profile_data(self): self.about_html = mistune.markdown(self.about_text) if self.display_picture: self.gravatar_hash = md5(self.email.lower().encode('utf-8')).hexdigest() def __unicode__(self): return "<RedditUser:{}>".format(self.user.username)
apache-2.0
[ 504, 8337, 492, 6128, 21, 199, 199, 646, 27572, 11474, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 9572, 1741, 1899, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 9, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1276, 12, 2973, 29, 549, 12, 849, 29, 403, 12, 3303, 4596, 29, 549, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1276, 12, 2973, 29, 549, 12, 849, 29, 403, 12, 639, 4596, 29, 549, 9, 272, 3031, 275, 1709, 14, 16577, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 849, 29, 403, 9, 272, 3595, 63, 505, 275, 1709, 14, 6254, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 1390, 63, 1267, 29, 5783, 12, 3303, 849, 29, 403, 9, 272, 3595, 63, 1360, 275, 1709, 14, 6254, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 849, 29, 403, 9, 272, 1999, 28694, 63, 2227, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 708, 12, 2973, 29, 549, 12, 4596, 29, 549, 12, 3660, 849, 29, 403, 9, 272, 2929, 63, 12538, 275, 1709, 14, 29068, 8, 885, 29, 797, 9, 272, 26586, 275, 1709, 14, 17363, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 849, 29, 403, 9, 272, 15811, 275, 1709, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 1390, 63, 1267, 29, 1046, 12, 3044, 849, 29, 403, 9, 272, 12869, 275, 1709, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 1390, 63, 1267, 29, 1355, 12, 2892, 849, 29, 403, 9, 339, 3721, 63, 20814, 275, 1709, 14, 3901, 8, 885, 29, 16, 9, 272, 2142, 63, 20814, 275, 1709, 14, 3901, 8, 885, 29, 16, 9, 339, 347, 1678, 63, 2913, 63, 576, 8, 277, 304, 267, 291, 14, 10254, 63, 1360, 275, 27572, 11474, 14, 15653, 8, 277, 14, 10254, 63, 505, 9, 267, 340, 291, 14, 2918, 63, 12538, 26, 288, 291, 14, 926, 28694, 63, 2227, 275, 6128, 21, 8, 277, 14, 2123, 14, 2325, 1252, 2143, 360, 1624, 13, 24, 11103, 11453, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 3886, 10858, 1741, 1899, 29930, 23167, 908, 8, 277, 14, 751, 14, 2473, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8337, 492, 6128, 21, 199, 199, 646, 27572, 11474, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 9572, 1741, 1899, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 9, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1276, 12, 2973, 29, 549, 12, 849, 29, 403, 12, 3303, 4596, 29, 549, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1276, 12, 2973, 29, 549, 12, 849, 29, 403, 12, 639, 4596, 29, 549, 9, 272, 3031, 275, 1709, 14, 16577, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 849, 29, 403, 9, 272, 3595, 63, 505, 275, 1709, 14, 6254, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 1390, 63, 1267, 29, 5783, 12, 3303, 849, 29, 403, 9, 272, 3595, 63, 1360, 275, 1709, 14, 6254, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 849, 29, 403, 9, 272, 1999, 28694, 63, 2227, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 708, 12, 2973, 29, 549, 12, 4596, 29, 549, 12, 3660, 849, 29, 403, 9, 272, 2929, 63, 12538, 275, 1709, 14, 29068, 8, 885, 29, 797, 9, 272, 26586, 275, 1709, 14, 17363, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 849, 29, 403, 9, 272, 15811, 275, 1709, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 1390, 63, 1267, 29, 1046, 12, 3044, 849, 29, 403, 9, 272, 12869, 275, 1709, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 549, 12, 1390, 63, 1267, 29, 1355, 12, 2892, 849, 29, 403, 9, 339, 3721, 63, 20814, 275, 1709, 14, 3901, 8, 885, 29, 16, 9, 272, 2142, 63, 20814, 275, 1709, 14, 3901, 8, 885, 29, 16, 9, 339, 347, 1678, 63, 2913, 63, 576, 8, 277, 304, 267, 291, 14, 10254, 63, 1360, 275, 27572, 11474, 14, 15653, 8, 277, 14, 10254, 63, 505, 9, 267, 340, 291, 14, 2918, 63, 12538, 26, 288, 291, 14, 926, 28694, 63, 2227, 275, 6128, 21, 8, 277, 14, 2123, 14, 2325, 1252, 2143, 360, 1624, 13, 24, 11103, 11453, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 3886, 10858, 1741, 1899, 29930, 23167, 908, 8, 277, 14, 751, 14, 2473, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
taaviteska/django
django/db/migrations/migration.py
24
8092
from django.db.transaction import atomic from .exceptions import IrreversibleError class Migration: """ The base class for all migrations. Migration files will import this from django.db.migrations.Migration and subclass it as a class called Migration. It will have one or more of the following attributes: - operations: A list of Operation instances, probably from django.db.migrations.operations - dependencies: A list of tuples of (app_path, migration_name) - run_before: A list of tuples of (app_path, migration_name) - replaces: A list of migration_names Note that all migrations come out of migrations and into the Loader or Graph as instances, having been initialized with their app label and name. """ # Operations to apply during this migration, in order. operations = [] # Other migrations that should be run before this migration. # Should be a list of (app, migration_name). dependencies = [] # Other migrations that should be run after this one (i.e. have # this migration added to their dependencies). Useful to make third-party # apps' migrations run after your AUTH_USER replacement, for example. run_before = [] # Migration names in this app that this migration replaces. If this is # non-empty, this migration will only be applied if all these migrations # are not applied. replaces = [] # Is this an initial migration? Initial migrations are skipped on # --fake-initial if the table or fields already exist. If None, check if # the migration has any dependencies to determine if there are dependencies # to tell if db introspection needs to be done. If True, always perform # introspection. If False, never perform introspection. initial = None # Whether to wrap the whole migration in a transaction. Only has an effect # on database backends which support transactional DDL. atomic = True def __init__(self, name, app_label): self.name = name self.app_label = app_label # Copy dependencies & other attrs as we might mutate them at runtime self.operations = list(self.__class__.operations) self.dependencies = list(self.__class__.dependencies) self.run_before = list(self.__class__.run_before) self.replaces = list(self.__class__.replaces) def __eq__(self, other): if not isinstance(other, Migration): return False return (self.name == other.name) and (self.app_label == other.app_label) def __repr__(self): return "<Migration %s.%s>" % (self.app_label, self.name) def __str__(self): return "%s.%s" % (self.app_label, self.name) def __hash__(self): return hash("%s.%s" % (self.app_label, self.name)) def mutate_state(self, project_state, preserve=True): """ Take a ProjectState and return a new one with the migration's operations applied to it. Preserve the original object state by default and return a mutated state from a copy. """ new_state = project_state if preserve: new_state = project_state.clone() for operation in self.operations: operation.state_forwards(self.app_label, new_state) return new_state def apply(self, project_state, schema_editor, collect_sql=False): """ Take a project_state representing all migrations prior to this one and a schema_editor for a live database and apply the migration in a forwards order. Return the resulting project state for efficient reuse by following Migrations. """ for operation in self.operations: # If this operation cannot be represented as SQL, place a comment # there instead if collect_sql: schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: schema_editor.collected_sql.append( "-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:" ) schema_editor.collected_sql.append("-- %s" % operation.describe()) schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: continue # Save the state before the operation has run old_state = project_state.clone() operation.state_forwards(self.app_label, project_state) # Run the operation atomic_operation = operation.atomic or (self.atomic and operation.atomic is not False) if not schema_editor.atomic_migration and atomic_operation: # Force a transaction on a non-transactional-DDL backend or an # atomic operation inside a non-atomic migration. with atomic(schema_editor.connection.alias): operation.database_forwards(self.app_label, schema_editor, old_state, project_state) else: # Normal behaviour operation.database_forwards(self.app_label, schema_editor, old_state, project_state) return project_state def unapply(self, project_state, schema_editor, collect_sql=False): """ Take a project_state representing all migrations prior to this one and a schema_editor for a live database and apply the migration in a reverse order. The backwards migration process consists of two phases: 1. The intermediate states from right before the first until right after the last operation inside this migration are preserved. 2. The operations are applied in reverse order using the states recorded in step 1. """ # Construct all the intermediate states we need for a reverse migration to_run = [] new_state = project_state # Phase 1 for operation in self.operations: # If it's irreversible, error out if not operation.reversible: raise IrreversibleError("Operation %s in %s is not reversible" % (operation, self)) # Preserve new state from previous run to not tamper the same state # over all operations new_state = new_state.clone() old_state = new_state.clone() operation.state_forwards(self.app_label, new_state) to_run.insert(0, (operation, old_state, new_state)) # Phase 2 for operation, to_state, from_state in to_run: if collect_sql: schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: schema_editor.collected_sql.append( "-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:" ) schema_editor.collected_sql.append("-- %s" % operation.describe()) schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: continue if not schema_editor.connection.features.can_rollback_ddl and operation.atomic: # We're forcing a transaction on a non-transactional-DDL backend with atomic(schema_editor.connection.alias): operation.database_backwards(self.app_label, schema_editor, from_state, to_state) else: # Normal behaviour operation.database_backwards(self.app_label, schema_editor, from_state, to_state) return project_state class SwappableTuple(tuple): """ Subclass of tuple so Django can tell this was originally a swappable dependency when it reads the migration file. """ def __new__(cls, value, setting): self = tuple.__new__(cls, value) self.setting = setting return self def swappable_dependency(value): """Turn a setting value into a dependency.""" return SwappableTuple((value.split(".", 1)[0], "__first__"), value)
bsd-3-clause
[ 504, 1639, 14, 697, 14, 5945, 492, 15374, 199, 199, 504, 1275, 3924, 492, 473, 82, 264, 422, 1164, 547, 421, 199, 533, 12090, 26, 272, 408, 272, 710, 1300, 1021, 367, 1006, 6180, 14, 339, 12090, 1584, 911, 492, 642, 687, 1639, 14, 697, 14, 7685, 14, 9816, 272, 436, 5516, 652, 465, 282, 1021, 2797, 12090, 14, 2779, 911, 1172, 1373, 503, 1655, 272, 402, 314, 2569, 3004, 26, 10813, 446, 5331, 26, 437, 769, 402, 17954, 4454, 12, 8646, 687, 1639, 14, 697, 14, 7685, 14, 8170, 1362, 446, 5124, 26, 437, 769, 402, 6346, 402, 334, 571, 63, 515, 12, 8367, 63, 354, 9, 1362, 446, 1255, 63, 5182, 26, 437, 769, 402, 6346, 402, 334, 571, 63, 515, 12, 8367, 63, 354, 9, 1362, 446, 19058, 26, 437, 769, 402, 8367, 63, 1247, 339, 3390, 626, 1006, 6180, 11492, 734, 402, 6180, 436, 1901, 314, 22865, 503, 272, 11513, 465, 4454, 12, 9445, 2757, 10038, 543, 3932, 1145, 1768, 436, 536, 14, 272, 408, 339, 327, 29474, 370, 4838, 5309, 642, 8367, 12, 315, 1865, 14, 272, 5331, 275, 942, 339, 327, 5439, 6180, 626, 1077, 506, 1255, 2544, 642, 8367, 14, 272, 327, 7719, 506, 282, 769, 402, 334, 571, 12, 8367, 63, 354, 680, 272, 5124, 275, 942, 339, 327, 5439, 6180, 626, 1077, 506, 1255, 2410, 642, 1373, 334, 73, 14, 69, 14, 1172, 272, 327, 642, 8367, 3483, 370, 3932, 5124, 680, 18491, 370, 1852, 10919, 13, 7522, 272, 327, 8686, 7, 6180, 1255, 2410, 2195, 7560, 63, 3791, 8343, 12, 367, 2893, 14, 272, 1255, 63, 5182, 275, 942, 339, 327, 12090, 1561, 315, 642, 1145, 626, 642, 8367, 19058, 14, 982, 642, 365, 272, 327, 2222, 13, 1667, 12, 642, 8367, 911, 1454, 506, 6781, 340, 1006, 3520, 6180, 272, 327, 787, 440, 6781, 14, 272, 19058, 275, 942, 339, 327, 6596, 642, 376, 2536, 8367, 31, 6026, 6180, 787, 9645, 641, 272, 327, 1553, 3183, 13, 2747, 340, 314, 1817, 503, 1504, 2575, 2187, 14, 982, 488, 12, 1104, 340, 272, 327, 314, 8367, 965, 1263, 5124, 370, 6705, 340, 2337, 787, 5124, 272, 327, 370, 11480, 340, 1592, 1109, 14254, 4839, 370, 506, 4224, 14, 982, 715, 12, 3544, 5147, 272, 327, 1109, 14254, 14, 982, 756, 12, 7078, 5147, 1109, 14254, 14, 272, 2536, 275, 488, 339, 327, 7480, 370, 4816, 314, 8852, 8367, 315, 282, 6008, 14, 5972, 965, 376, 7763, 272, 327, 641, 3050, 14745, 1314, 2291, 6008, 279, 32078, 14, 272, 15374, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1145, 63, 1302, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 571, 63, 1302, 275, 1145, 63, 1302, 267, 327, 11247, 5124, 1253, 1163, 3290, 465, 781, 5594, 31173, 3062, 737, 8836, 267, 291, 14, 8170, 275, 769, 8, 277, 855, 533, 4343, 8170, 9, 267, 291, 14, 5714, 275, 769, 8, 277, 855, 533, 4343, 5714, 9, 267, 291, 14, 1065, 63, 5182, 275, 769, 8, 277, 855, 533, 4343, 1065, 63, 5182, 9, 267, 291, 14, 1155, 5862, 275, 769, 8, 277, 855, 533, 4343, 1155, 5862, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 12090, 304, 288, 372, 756, 267, 372, 334, 277, 14, 354, 508, 1163, 14, 354, 9, 436, 334, 277, 14, 571, 63, 1302, 508, 1163, 14, 571, 63, 1302, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 9816, 450, 83, 4111, 83, 4335, 450, 334, 277, 14, 571, 63, 1302, 12, 291, 14, 354, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 4111, 83, 2, 450, 334, 277, 14, 571, 63, 1302, 12, 291, 14, 354, 9, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 3647, 83, 4111, 83, 2, 450, 334, 277, 14, 571, 63, 1302, 12, 291, 14, 354, 430, 339, 347, 31173, 63, 929, 8, 277, 12, 2199, 63, 929, 12, 11211, 29, 549, 304, 267, 408, 267, 18146, 282, 7290, 2223, 436, 372, 282, 892, 1373, 543, 314, 8367, 1159, 267, 5331, 6781, 370, 652, 14, 5543, 4909, 314, 3379, 909, 1174, 701, 267, 849, 436, 372, 282, 8567, 972, 1174, 687, 282, 1331, 14, 267, 408, 267, 892, 63, 929, 275, 2199, 63, 929, 267, 340, 11211, 26, 288, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 398, 367, 3439, 315, 291, 14, 8170, 26, 288, 3439, 14, 929, 63, 19159, 8, 277, 14, 571, 63, 1302, 12, 892, 63, 929, 9, 267, 372, 892, 63, 929, 339, 347, 4838, 8, 277, 12, 2199, 63, 929, 12, 4177, 63, 7515, 12, 8775, 63, 3009, 29, 797, 304, 267, 408, 267, 18146, 282, 2199, 63, 929, 6144, 1006, 6180, 6791, 370, 642, 1373, 267, 436, 282, 4177, 63, 7515, 367, 282, 12166, 3050, 436, 4838, 314, 8367, 267, 315, 282, 17465, 1865, 14, 398, 1432, 314, 9183, 2199, 1174, 367, 13402, 12598, 701, 2569, 267, 28195, 3801, 14, 267, 408, 267, 367, 3439, 315, 291, 14, 8170, 26, 288, 327, 982, 642, 3439, 3913, 506, 11159, 465, 5385, 12, 4192, 282, 3721, 288, 327, 2337, 3140, 288, 340, 8775, 63, 3009, 26, 355, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 6739, 531, 355, 340, 440, 3439, 14, 19493, 823, 63, 475, 63, 3009, 26, 490, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 8, 717, 4320, 603, 1277, 23743, 4825, 55, 13873, 11518, 29771, 2594, 4221, 619, 29661, 4609, 6262, 16573, 20779, 742, 4319, 5385, 5424, 490, 776, 355, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 6739, 450, 83, 2, 450, 3439, 14, 11935, 1012, 355, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 6739, 531, 355, 340, 440, 3439, 14, 19493, 823, 63, 475, 63, 3009, 26, 490, 1980, 288, 327, 11063, 314, 1174, 2544, 314, 3439, 965, 1255, 288, 2269, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 288, 3439, 14, 929, 63, 19159, 8, 277, 14, 571, 63, 1302, 12, 2199, 63, 929, 9, 288, 327, 3378, 314, 3439, 288, 15374, 63, 5735, 275, 3439, 14, 10910, 503, 334, 277, 14 ]
[ 1639, 14, 697, 14, 5945, 492, 15374, 199, 199, 504, 1275, 3924, 492, 473, 82, 264, 422, 1164, 547, 421, 199, 533, 12090, 26, 272, 408, 272, 710, 1300, 1021, 367, 1006, 6180, 14, 339, 12090, 1584, 911, 492, 642, 687, 1639, 14, 697, 14, 7685, 14, 9816, 272, 436, 5516, 652, 465, 282, 1021, 2797, 12090, 14, 2779, 911, 1172, 1373, 503, 1655, 272, 402, 314, 2569, 3004, 26, 10813, 446, 5331, 26, 437, 769, 402, 17954, 4454, 12, 8646, 687, 1639, 14, 697, 14, 7685, 14, 8170, 1362, 446, 5124, 26, 437, 769, 402, 6346, 402, 334, 571, 63, 515, 12, 8367, 63, 354, 9, 1362, 446, 1255, 63, 5182, 26, 437, 769, 402, 6346, 402, 334, 571, 63, 515, 12, 8367, 63, 354, 9, 1362, 446, 19058, 26, 437, 769, 402, 8367, 63, 1247, 339, 3390, 626, 1006, 6180, 11492, 734, 402, 6180, 436, 1901, 314, 22865, 503, 272, 11513, 465, 4454, 12, 9445, 2757, 10038, 543, 3932, 1145, 1768, 436, 536, 14, 272, 408, 339, 327, 29474, 370, 4838, 5309, 642, 8367, 12, 315, 1865, 14, 272, 5331, 275, 942, 339, 327, 5439, 6180, 626, 1077, 506, 1255, 2544, 642, 8367, 14, 272, 327, 7719, 506, 282, 769, 402, 334, 571, 12, 8367, 63, 354, 680, 272, 5124, 275, 942, 339, 327, 5439, 6180, 626, 1077, 506, 1255, 2410, 642, 1373, 334, 73, 14, 69, 14, 1172, 272, 327, 642, 8367, 3483, 370, 3932, 5124, 680, 18491, 370, 1852, 10919, 13, 7522, 272, 327, 8686, 7, 6180, 1255, 2410, 2195, 7560, 63, 3791, 8343, 12, 367, 2893, 14, 272, 1255, 63, 5182, 275, 942, 339, 327, 12090, 1561, 315, 642, 1145, 626, 642, 8367, 19058, 14, 982, 642, 365, 272, 327, 2222, 13, 1667, 12, 642, 8367, 911, 1454, 506, 6781, 340, 1006, 3520, 6180, 272, 327, 787, 440, 6781, 14, 272, 19058, 275, 942, 339, 327, 6596, 642, 376, 2536, 8367, 31, 6026, 6180, 787, 9645, 641, 272, 327, 1553, 3183, 13, 2747, 340, 314, 1817, 503, 1504, 2575, 2187, 14, 982, 488, 12, 1104, 340, 272, 327, 314, 8367, 965, 1263, 5124, 370, 6705, 340, 2337, 787, 5124, 272, 327, 370, 11480, 340, 1592, 1109, 14254, 4839, 370, 506, 4224, 14, 982, 715, 12, 3544, 5147, 272, 327, 1109, 14254, 14, 982, 756, 12, 7078, 5147, 1109, 14254, 14, 272, 2536, 275, 488, 339, 327, 7480, 370, 4816, 314, 8852, 8367, 315, 282, 6008, 14, 5972, 965, 376, 7763, 272, 327, 641, 3050, 14745, 1314, 2291, 6008, 279, 32078, 14, 272, 15374, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1145, 63, 1302, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 571, 63, 1302, 275, 1145, 63, 1302, 267, 327, 11247, 5124, 1253, 1163, 3290, 465, 781, 5594, 31173, 3062, 737, 8836, 267, 291, 14, 8170, 275, 769, 8, 277, 855, 533, 4343, 8170, 9, 267, 291, 14, 5714, 275, 769, 8, 277, 855, 533, 4343, 5714, 9, 267, 291, 14, 1065, 63, 5182, 275, 769, 8, 277, 855, 533, 4343, 1065, 63, 5182, 9, 267, 291, 14, 1155, 5862, 275, 769, 8, 277, 855, 533, 4343, 1155, 5862, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 12090, 304, 288, 372, 756, 267, 372, 334, 277, 14, 354, 508, 1163, 14, 354, 9, 436, 334, 277, 14, 571, 63, 1302, 508, 1163, 14, 571, 63, 1302, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 9816, 450, 83, 4111, 83, 4335, 450, 334, 277, 14, 571, 63, 1302, 12, 291, 14, 354, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 4111, 83, 2, 450, 334, 277, 14, 571, 63, 1302, 12, 291, 14, 354, 9, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 3647, 83, 4111, 83, 2, 450, 334, 277, 14, 571, 63, 1302, 12, 291, 14, 354, 430, 339, 347, 31173, 63, 929, 8, 277, 12, 2199, 63, 929, 12, 11211, 29, 549, 304, 267, 408, 267, 18146, 282, 7290, 2223, 436, 372, 282, 892, 1373, 543, 314, 8367, 1159, 267, 5331, 6781, 370, 652, 14, 5543, 4909, 314, 3379, 909, 1174, 701, 267, 849, 436, 372, 282, 8567, 972, 1174, 687, 282, 1331, 14, 267, 408, 267, 892, 63, 929, 275, 2199, 63, 929, 267, 340, 11211, 26, 288, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 398, 367, 3439, 315, 291, 14, 8170, 26, 288, 3439, 14, 929, 63, 19159, 8, 277, 14, 571, 63, 1302, 12, 892, 63, 929, 9, 267, 372, 892, 63, 929, 339, 347, 4838, 8, 277, 12, 2199, 63, 929, 12, 4177, 63, 7515, 12, 8775, 63, 3009, 29, 797, 304, 267, 408, 267, 18146, 282, 2199, 63, 929, 6144, 1006, 6180, 6791, 370, 642, 1373, 267, 436, 282, 4177, 63, 7515, 367, 282, 12166, 3050, 436, 4838, 314, 8367, 267, 315, 282, 17465, 1865, 14, 398, 1432, 314, 9183, 2199, 1174, 367, 13402, 12598, 701, 2569, 267, 28195, 3801, 14, 267, 408, 267, 367, 3439, 315, 291, 14, 8170, 26, 288, 327, 982, 642, 3439, 3913, 506, 11159, 465, 5385, 12, 4192, 282, 3721, 288, 327, 2337, 3140, 288, 340, 8775, 63, 3009, 26, 355, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 6739, 531, 355, 340, 440, 3439, 14, 19493, 823, 63, 475, 63, 3009, 26, 490, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 8, 717, 4320, 603, 1277, 23743, 4825, 55, 13873, 11518, 29771, 2594, 4221, 619, 29661, 4609, 6262, 16573, 20779, 742, 4319, 5385, 5424, 490, 776, 355, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 6739, 450, 83, 2, 450, 3439, 14, 11935, 1012, 355, 4177, 63, 7515, 14, 22766, 63, 3009, 14, 740, 6739, 531, 355, 340, 440, 3439, 14, 19493, 823, 63, 475, 63, 3009, 26, 490, 1980, 288, 327, 11063, 314, 1174, 2544, 314, 3439, 965, 1255, 288, 2269, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 288, 3439, 14, 929, 63, 19159, 8, 277, 14, 571, 63, 1302, 12, 2199, 63, 929, 9, 288, 327, 3378, 314, 3439, 288, 15374, 63, 5735, 275, 3439, 14, 10910, 503, 334, 277, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
selentd/pythontools
pytools/src/oldsrc/addindex.py
1
2335
import datetime import pymongo from pymongo.mongo_client import MongoClient import indexdata def getIndexEntry( indexData ): return indexData.getDictionary() def getIndexDateEntry( indexData ): return { "date": datetime.datetime(indexData.date.year, indexData.date.month, indexData.date.day, 0, 0) } def getIndexHistory( source, size = 10000000 ): indexHistory = indexdata.IndexHistory(source, size) indexHistory.readIndex() return indexHistory def addIndex( source, dbName, indexName ): #client = MongoClient("192.168.81.147") client = MongoClient("127.0.0.1") database = client[dbName] collection = database[indexName] collection.create_index([("date", pymongo.ASCENDING)], name="date", unique=True) indexHistory = getIndexHistory(source) for indexData in indexHistory.indexHistory: indexEntry = getIndexEntry(indexData) indexDate = getIndexDateEntry(indexData) if collection.find_one(indexDate) == None: collection.insert(indexEntry) def addIndizes(): ''' addIndex('../../data/sp500.csv', 'stockdb', 'sp500') addIndex('../../data/tecdax.csv', 'stockdb', 'tecdax') addIndex('../../data/mdax.csv', 'stockdb', 'mdax') addIndex('../../data/nasdaq100.csv', 'stockdb', 'nasdaq100') addIndex('../../data/smi.csv', 'stockdb', 'smi') addIndex('../../data/tecdax.csv', 'stockdb', 'tecdax') ''' indexList = ['atx', 'brent', 'cac', 'dax', 'dowjones', 'estoxx50', 'ftse100', 'ftsemib', 'gold', 'hangseng', 'hscei', 'ibex', 'mdax', 'nasdaq100', 'nikkei', 'sdax', 'smi', 'sp500', 'tecdax'] for index in indexList: print '../../data/'+index+'.csv' addIndex('../../data/'+index+'.csv', 'stockdb', index) if __name__ == '__main__': addIndizes()
apache-2.0
[ 199, 646, 2197, 199, 199, 646, 21878, 199, 504, 21878, 14, 9217, 63, 1258, 492, 13503, 3041, 199, 199, 646, 1478, 576, 199, 199, 318, 664, 2681, 3900, 8, 1478, 1451, 3461, 272, 372, 1478, 1451, 14, 362, 11728, 342, 199, 199, 318, 664, 2681, 2506, 3900, 8, 1478, 1451, 3461, 272, 372, 469, 298, 602, 582, 2197, 14, 2083, 8, 1080, 1451, 14, 602, 14, 3403, 12, 4318, 1478, 1451, 14, 602, 14, 4482, 12, 4318, 1478, 1451, 14, 602, 14, 2977, 12, 4318, 378, 12, 4318, 378, 9, 288, 789, 199, 199, 318, 664, 2681, 12114, 8, 1350, 12, 1568, 275, 413, 9084, 3461, 272, 1478, 12114, 275, 1478, 576, 14, 2681, 12114, 8, 1365, 12, 1568, 9, 272, 1478, 12114, 14, 739, 2681, 342, 272, 372, 1478, 12114, 199, 199, 318, 1050, 2681, 8, 1350, 12, 1592, 985, 12, 1478, 985, 3461, 272, 327, 1258, 275, 13503, 3041, 480, 5756, 14, 6568, 14, 2835, 14, 11160, 531, 272, 1890, 275, 13503, 3041, 480, 4195, 14, 16, 14, 16, 14, 17, 531, 272, 3050, 275, 1890, 59, 697, 985, 61, 272, 3245, 275, 3050, 59, 1080, 985, 61, 272, 3245, 14, 981, 63, 1080, 27187, 602, 401, 21878, 14, 22767, 15219, 4360, 1169, 536, 628, 602, 401, 1169, 3747, 29, 549, 9, 272, 1478, 12114, 275, 664, 2681, 12114, 8, 1365, 9, 272, 367, 1478, 1451, 315, 1478, 12114, 14, 1080, 12114, 26, 267, 1478, 3900, 275, 664, 2681, 3900, 8, 1080, 1451, 9, 267, 1478, 2506, 275, 664, 2681, 2506, 3900, 8, 1080, 1451, 9, 267, 340, 3245, 14, 1623, 63, 368, 8, 1080, 2506, 9, 508, 488, 26, 288, 3245, 14, 3176, 8, 1080, 3900, 9, 199, 199, 318, 1050, 607, 328, 90, 397, 837, 272, 1449, 272, 1050, 2681, 360, 9707, 576, 15, 681, 5783, 14, 4737, 297, 283, 6088, 697, 297, 283, 681, 5783, 358, 272, 1050, 2681, 360, 9707, 576, 15, 266, 67, 983, 88, 14, 4737, 297, 283, 6088, 697, 297, 283, 266, 67, 983, 88, 358, 17635, 1050, 2681, 360, 9707, 576, 15, 77, 983, 88, 14, 4737, 297, 283, 6088, 697, 297, 283, 77, 983, 88, 358, 339, 1050, 2681, 360, 9707, 576, 15, 24292, 983, 81, 1960, 14, 4737, 297, 283, 6088, 697, 297, 283, 24292, 983, 81, 1960, 358, 272, 1050, 2681, 360, 9707, 576, 15, 83, 2664, 14, 4737, 297, 283, 6088, 697, 297, 283, 83, 2664, 358, 272, 1050, 2681, 360, 9707, 576, 15, 266, 67, 983, 88, 14, 4737, 297, 283, 6088, 697, 297, 283, 266, 67, 983, 88, 358, 272, 1449, 272, 1478, 1296, 275, 788, 292, 88, 297, 326, 283, 66, 640, 297, 326, 283, 11055, 297, 326, 283, 983, 88, 297, 326, 283, 68, 583, 74, 4548, 297, 326, 283, 597, 79, 2154, 1400, 297, 326, 283, 856, 261, 1960, 297, 326, 283, 856, 21678, 1892, 297, 326, 283, 23628, 297, 326, 283, 27304, 2464, 71, 297, 326, 283, 4213, 301, 73, 297, 326, 283, 1892, 476, 297, 326, 283, 77, 983, 88, 297, 326, 283, 24292, 983, 81, 1960, 297, 326, 283, 22998, 415, 73, 297, 326, 283, 19387, 88, 297, 326, 283, 83, 2664, 297, 326, 283, 681, 5783, 297, 326, 283, 266, 67, 983, 88, 418, 2286, 367, 1478, 315, 1478, 1296, 26, 267, 870, 283, 9707, 576, 19047, 1080, 18098, 4737, 7, 267, 1050, 2681, 360, 9707, 576, 19047, 1080, 18098, 4737, 297, 283, 6088, 697, 297, 1478, 9, 1362, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1050, 607, 328, 90, 397, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 646, 2197, 199, 199, 646, 21878, 199, 504, 21878, 14, 9217, 63, 1258, 492, 13503, 3041, 199, 199, 646, 1478, 576, 199, 199, 318, 664, 2681, 3900, 8, 1478, 1451, 3461, 272, 372, 1478, 1451, 14, 362, 11728, 342, 199, 199, 318, 664, 2681, 2506, 3900, 8, 1478, 1451, 3461, 272, 372, 469, 298, 602, 582, 2197, 14, 2083, 8, 1080, 1451, 14, 602, 14, 3403, 12, 4318, 1478, 1451, 14, 602, 14, 4482, 12, 4318, 1478, 1451, 14, 602, 14, 2977, 12, 4318, 378, 12, 4318, 378, 9, 288, 789, 199, 199, 318, 664, 2681, 12114, 8, 1350, 12, 1568, 275, 413, 9084, 3461, 272, 1478, 12114, 275, 1478, 576, 14, 2681, 12114, 8, 1365, 12, 1568, 9, 272, 1478, 12114, 14, 739, 2681, 342, 272, 372, 1478, 12114, 199, 199, 318, 1050, 2681, 8, 1350, 12, 1592, 985, 12, 1478, 985, 3461, 272, 327, 1258, 275, 13503, 3041, 480, 5756, 14, 6568, 14, 2835, 14, 11160, 531, 272, 1890, 275, 13503, 3041, 480, 4195, 14, 16, 14, 16, 14, 17, 531, 272, 3050, 275, 1890, 59, 697, 985, 61, 272, 3245, 275, 3050, 59, 1080, 985, 61, 272, 3245, 14, 981, 63, 1080, 27187, 602, 401, 21878, 14, 22767, 15219, 4360, 1169, 536, 628, 602, 401, 1169, 3747, 29, 549, 9, 272, 1478, 12114, 275, 664, 2681, 12114, 8, 1365, 9, 272, 367, 1478, 1451, 315, 1478, 12114, 14, 1080, 12114, 26, 267, 1478, 3900, 275, 664, 2681, 3900, 8, 1080, 1451, 9, 267, 1478, 2506, 275, 664, 2681, 2506, 3900, 8, 1080, 1451, 9, 267, 340, 3245, 14, 1623, 63, 368, 8, 1080, 2506, 9, 508, 488, 26, 288, 3245, 14, 3176, 8, 1080, 3900, 9, 199, 199, 318, 1050, 607, 328, 90, 397, 837, 272, 1449, 272, 1050, 2681, 360, 9707, 576, 15, 681, 5783, 14, 4737, 297, 283, 6088, 697, 297, 283, 681, 5783, 358, 272, 1050, 2681, 360, 9707, 576, 15, 266, 67, 983, 88, 14, 4737, 297, 283, 6088, 697, 297, 283, 266, 67, 983, 88, 358, 17635, 1050, 2681, 360, 9707, 576, 15, 77, 983, 88, 14, 4737, 297, 283, 6088, 697, 297, 283, 77, 983, 88, 358, 339, 1050, 2681, 360, 9707, 576, 15, 24292, 983, 81, 1960, 14, 4737, 297, 283, 6088, 697, 297, 283, 24292, 983, 81, 1960, 358, 272, 1050, 2681, 360, 9707, 576, 15, 83, 2664, 14, 4737, 297, 283, 6088, 697, 297, 283, 83, 2664, 358, 272, 1050, 2681, 360, 9707, 576, 15, 266, 67, 983, 88, 14, 4737, 297, 283, 6088, 697, 297, 283, 266, 67, 983, 88, 358, 272, 1449, 272, 1478, 1296, 275, 788, 292, 88, 297, 326, 283, 66, 640, 297, 326, 283, 11055, 297, 326, 283, 983, 88, 297, 326, 283, 68, 583, 74, 4548, 297, 326, 283, 597, 79, 2154, 1400, 297, 326, 283, 856, 261, 1960, 297, 326, 283, 856, 21678, 1892, 297, 326, 283, 23628, 297, 326, 283, 27304, 2464, 71, 297, 326, 283, 4213, 301, 73, 297, 326, 283, 1892, 476, 297, 326, 283, 77, 983, 88, 297, 326, 283, 24292, 983, 81, 1960, 297, 326, 283, 22998, 415, 73, 297, 326, 283, 19387, 88, 297, 326, 283, 83, 2664, 297, 326, 283, 681, 5783, 297, 326, 283, 266, 67, 983, 88, 418, 2286, 367, 1478, 315, 1478, 1296, 26, 267, 870, 283, 9707, 576, 19047, 1080, 18098, 4737, 7, 267, 1050, 2681, 360, 9707, 576, 19047, 1080, 18098, 4737, 297, 283, 6088, 697, 297, 1478, 9, 1362, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 1050, 607, 328, 90, 397, 342, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
idwanglu2010/git-repo
subcmds/cherry_pick.py
48
3349
# # Copyright (C) 2010 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import re import sys from command import Command from git_command import GitCommand CHANGE_ID_RE = re.compile(r'^\s*Change-Id: I([0-9a-f]{40})\s*$') class CherryPick(Command): common = True helpSummary = "Cherry-pick a change." helpUsage = """ %prog <sha1> """ helpDescription = """ '%prog' cherry-picks a change from one branch to another. The change id will be updated, and a reference to the old change id will be added. """ def _Options(self, p): pass def Execute(self, opt, args): if len(args) != 1: self.Usage() reference = args[0] p = GitCommand(None, ['rev-parse', '--verify', reference], capture_stdout = True, capture_stderr = True) if p.Wait() != 0: print >>sys.stderr, p.stderr sys.exit(1) sha1 = p.stdout.strip() p = GitCommand(None, ['cat-file', 'commit', sha1], capture_stdout=True) if p.Wait() != 0: print >>sys.stderr, "error: Failed to retrieve old commit message" sys.exit(1) old_msg = self._StripHeader(p.stdout) p = GitCommand(None, ['cherry-pick', sha1], capture_stdout = True, capture_stderr = True) status = p.Wait() print >>sys.stdout, p.stdout print >>sys.stderr, p.stderr if status == 0: # The cherry-pick was applied correctly. We just need to edit the # commit message. new_msg = self._Reformat(old_msg, sha1) p = GitCommand(None, ['commit', '--amend', '-F', '-'], provide_stdin = True, capture_stdout = True, capture_stderr = True) p.stdin.write(new_msg) if p.Wait() != 0: print >>sys.stderr, "error: Failed to update commit message" sys.exit(1) else: print >>sys.stderr, """\ NOTE: When committing (please see above) and editing the commit message, please remove the old Change-Id-line and add: """ print >>sys.stderr, self._GetReference(sha1) print >>sys.stderr def _IsChangeId(self, line): return CHANGE_ID_RE.match(line) def _GetReference(self, sha1): return "(cherry picked from commit %s)" % sha1 def _StripHeader(self, commit_msg): lines = commit_msg.splitlines() return "\n".join(lines[lines.index("")+1:]) def _Reformat(self, old_msg, sha1): new_msg = [] for line in old_msg.splitlines(): if not self._IsChangeId(line): new_msg.append(line) # Add a blank line between the message and the change id/reference try: if new_msg[-1].strip() != "": new_msg.append("") except IndexError: pass new_msg.append(self._GetReference(sha1)) return "\n".join(new_msg)
apache-2.0
[ 3, 199, 3, 1898, 334, 35, 9, 7129, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 646, 984, 199, 504, 1414, 492, 5817, 199, 504, 6135, 63, 1531, 492, 12579, 3110, 199, 199, 16062, 63, 998, 63, 907, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 4001, 13, 1304, 26, 473, 779, 16, 13, 25, 65, 13, 70, 8194, 2167, 30446, 83, 10, 9988, 199, 199, 533, 30992, 651, 8587, 8, 3110, 304, 523, 2863, 275, 715, 523, 1720, 10407, 275, 298, 1049, 281, 651, 13, 4510, 282, 1570, 2122, 523, 1720, 7692, 275, 408, 199, 5, 6595, 665, 4835, 17, 30, 199, 624, 523, 1720, 5831, 275, 408, 199, 5956, 6595, 7, 12907, 651, 13, 4510, 83, 282, 1570, 687, 1373, 5246, 370, 4573, 14, 199, 1918, 1570, 1305, 911, 506, 4588, 12, 436, 282, 3659, 370, 314, 2269, 199, 1461, 1305, 911, 506, 3483, 14, 199, 624, 819, 347, 485, 4558, 8, 277, 12, 299, 304, 272, 986, 819, 347, 17009, 8, 277, 12, 2450, 12, 1249, 304, 272, 340, 822, 8, 589, 9, 1137, 413, 26, 489, 291, 14, 7692, 342, 339, 3659, 275, 1249, 59, 16, 61, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 4964, 13, 1122, 297, 2850, 4712, 297, 3659, 467, 673, 12296, 63, 2703, 275, 715, 12, 673, 12296, 63, 3083, 275, 715, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 4331, 1274, 14, 3083, 12, 299, 14, 3083, 489, 984, 14, 2224, 8, 17, 9, 272, 7793, 17, 275, 299, 14, 2703, 14, 1913, 342, 339, 299, 275, 12579, 3110, 8, 403, 12, 788, 3385, 13, 493, 297, 283, 3543, 297, 7793, 17, 467, 12296, 63, 2703, 29, 549, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 4331, 1274, 14, 3083, 12, 298, 705, 26, 16277, 370, 8044, 2269, 5532, 1245, 2, 489, 984, 14, 2224, 8, 17, 9, 272, 2269, 63, 1328, 275, 291, 423, 21332, 2567, 8, 80, 14, 2703, 9, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 7641, 651, 13, 4510, 297, 7793, 17, 467, 673, 12296, 63, 2703, 275, 715, 12, 673, 12296, 63, 3083, 275, 715, 9, 272, 2004, 275, 299, 14, 7536, 342, 339, 870, 4331, 1274, 14, 2703, 12, 299, 14, 2703, 272, 870, 4331, 1274, 14, 3083, 12, 299, 14, 3083, 339, 340, 2004, 508, 378, 26, 489, 327, 710, 12907, 651, 13, 4510, 1990, 6781, 6657, 14, 2136, 2951, 1929, 370, 5283, 314, 489, 327, 5532, 1245, 14, 489, 892, 63, 1328, 275, 291, 423, 497, 908, 8, 1753, 63, 1328, 12, 7793, 17, 9, 2541, 299, 275, 12579, 3110, 8, 403, 12, 788, 3543, 297, 2850, 313, 977, 297, 2475, 38, 297, 2475, 995, 2151, 5647, 63, 6626, 275, 715, 12, 2151, 12296, 63, 2703, 275, 715, 12, 2151, 12296, 63, 3083, 275, 715, 9, 489, 299, 14, 6626, 14, 952, 8, 1222, 63, 1328, 9, 489, 340, 299, 14, 7536, 342, 1137, 378, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 705, 26, 16277, 370, 1678, 5532, 1245, 2, 267, 984, 14, 2224, 8, 17, 9, 339, 587, 26, 489, 870, 4331, 1274, 14, 3083, 12, 9638, 199, 19855, 26, 3979, 5532, 1337, 334, 27567, 1937, 3432, 9, 436, 20401, 314, 5532, 1245, 12, 199, 27567, 2813, 314, 2269, 7743, 13, 1304, 13, 604, 436, 1050, 26, 199, 624, 489, 870, 4331, 1274, 14, 3083, 12, 291, 423, 1002, 5083, 8, 4835, 17, 9, 489, 870, 4331, 1274, 14, 3083, 819, 347, 485, 1831, 4001, 1304, 8, 277, 12, 1004, 304, 272, 372, 6624, 9011, 63, 998, 63, 907, 14, 1431, 8, 604, 9, 819, 347, 485, 1002, 5083, 8, 277, 12, 7793, 17, 304, 272, 372, 7340, 7641, 651, 29438, 687, 5532, 450, 83, 2924, 450, 7793, 17, 819, 347, 485, 21332, 2567, 8, 277, 12, 5532, 63, 1328, 304, 272, 2385, 275, 5532, 63, 1328, 14, 7644, 342, 272, 372, 1867, 78, 1674, 904, 8, 1278, 59, 1278, 14, 1080, 11986, 6393, 17, 5728, 819, 347, 485, 497, 908, 8, 277, 12, 2269, 63, 1328, 12, 7793, 17, 304, 272, 892, 63, 1328, 275, 942, 339, 367, 1004, 315, 2269, 63, 1328, 14, 7644, 837, 489, 340, 440, 291, 423, 1831, 4001, 1304, 8, 604, 304, 267, 892, 63, 1328, 14, 740, 8, 604, 9, 339, 327, 2654, 282, 4596, 1004, 3382, 314, 1245, 436, 314, 1570, 1305, 15, 4443, 272, 862, 26, 489, 340, 892, 63, 1328, 1988, 17, 1055, 1913, 342, 1137, 10812, 267, 892, 63, 1328, 14, 740, 10804, 272, 871, 7888, 26, 489, 986, 339, 892, 63, 1328, 14, 740, 8, 277, 423, 1002, 5083, 8, 4835, 17, 430, 272, 372, 1867, 78, 1674, 904, 8, 1222, 63, 1328, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 35, 9, 7129, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 295, 199, 646, 984, 199, 504, 1414, 492, 5817, 199, 504, 6135, 63, 1531, 492, 12579, 3110, 199, 199, 16062, 63, 998, 63, 907, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 4001, 13, 1304, 26, 473, 779, 16, 13, 25, 65, 13, 70, 8194, 2167, 30446, 83, 10, 9988, 199, 199, 533, 30992, 651, 8587, 8, 3110, 304, 523, 2863, 275, 715, 523, 1720, 10407, 275, 298, 1049, 281, 651, 13, 4510, 282, 1570, 2122, 523, 1720, 7692, 275, 408, 199, 5, 6595, 665, 4835, 17, 30, 199, 624, 523, 1720, 5831, 275, 408, 199, 5956, 6595, 7, 12907, 651, 13, 4510, 83, 282, 1570, 687, 1373, 5246, 370, 4573, 14, 199, 1918, 1570, 1305, 911, 506, 4588, 12, 436, 282, 3659, 370, 314, 2269, 199, 1461, 1305, 911, 506, 3483, 14, 199, 624, 819, 347, 485, 4558, 8, 277, 12, 299, 304, 272, 986, 819, 347, 17009, 8, 277, 12, 2450, 12, 1249, 304, 272, 340, 822, 8, 589, 9, 1137, 413, 26, 489, 291, 14, 7692, 342, 339, 3659, 275, 1249, 59, 16, 61, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 4964, 13, 1122, 297, 2850, 4712, 297, 3659, 467, 673, 12296, 63, 2703, 275, 715, 12, 673, 12296, 63, 3083, 275, 715, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 4331, 1274, 14, 3083, 12, 299, 14, 3083, 489, 984, 14, 2224, 8, 17, 9, 272, 7793, 17, 275, 299, 14, 2703, 14, 1913, 342, 339, 299, 275, 12579, 3110, 8, 403, 12, 788, 3385, 13, 493, 297, 283, 3543, 297, 7793, 17, 467, 12296, 63, 2703, 29, 549, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 4331, 1274, 14, 3083, 12, 298, 705, 26, 16277, 370, 8044, 2269, 5532, 1245, 2, 489, 984, 14, 2224, 8, 17, 9, 272, 2269, 63, 1328, 275, 291, 423, 21332, 2567, 8, 80, 14, 2703, 9, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 7641, 651, 13, 4510, 297, 7793, 17, 467, 673, 12296, 63, 2703, 275, 715, 12, 673, 12296, 63, 3083, 275, 715, 9, 272, 2004, 275, 299, 14, 7536, 342, 339, 870, 4331, 1274, 14, 2703, 12, 299, 14, 2703, 272, 870, 4331, 1274, 14, 3083, 12, 299, 14, 3083, 339, 340, 2004, 508, 378, 26, 489, 327, 710, 12907, 651, 13, 4510, 1990, 6781, 6657, 14, 2136, 2951, 1929, 370, 5283, 314, 489, 327, 5532, 1245, 14, 489, 892, 63, 1328, 275, 291, 423, 497, 908, 8, 1753, 63, 1328, 12, 7793, 17, 9, 2541, 299, 275, 12579, 3110, 8, 403, 12, 788, 3543, 297, 2850, 313, 977, 297, 2475, 38, 297, 2475, 995, 2151, 5647, 63, 6626, 275, 715, 12, 2151, 12296, 63, 2703, 275, 715, 12, 2151, 12296, 63, 3083, 275, 715, 9, 489, 299, 14, 6626, 14, 952, 8, 1222, 63, 1328, 9, 489, 340, 299, 14, 7536, 342, 1137, 378, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 705, 26, 16277, 370, 1678, 5532, 1245, 2, 267, 984, 14, 2224, 8, 17, 9, 339, 587, 26, 489, 870, 4331, 1274, 14, 3083, 12, 9638, 199, 19855, 26, 3979, 5532, 1337, 334, 27567, 1937, 3432, 9, 436, 20401, 314, 5532, 1245, 12, 199, 27567, 2813, 314, 2269, 7743, 13, 1304, 13, 604, 436, 1050, 26, 199, 624, 489, 870, 4331, 1274, 14, 3083, 12, 291, 423, 1002, 5083, 8, 4835, 17, 9, 489, 870, 4331, 1274, 14, 3083, 819, 347, 485, 1831, 4001, 1304, 8, 277, 12, 1004, 304, 272, 372, 6624, 9011, 63, 998, 63, 907, 14, 1431, 8, 604, 9, 819, 347, 485, 1002, 5083, 8, 277, 12, 7793, 17, 304, 272, 372, 7340, 7641, 651, 29438, 687, 5532, 450, 83, 2924, 450, 7793, 17, 819, 347, 485, 21332, 2567, 8, 277, 12, 5532, 63, 1328, 304, 272, 2385, 275, 5532, 63, 1328, 14, 7644, 342, 272, 372, 1867, 78, 1674, 904, 8, 1278, 59, 1278, 14, 1080, 11986, 6393, 17, 5728, 819, 347, 485, 497, 908, 8, 277, 12, 2269, 63, 1328, 12, 7793, 17, 304, 272, 892, 63, 1328, 275, 942, 339, 367, 1004, 315, 2269, 63, 1328, 14, 7644, 837, 489, 340, 440, 291, 423, 1831, 4001, 1304, 8, 604, 304, 267, 892, 63, 1328, 14, 740, 8, 604, 9, 339, 327, 2654, 282, 4596, 1004, 3382, 314, 1245, 436, 314, 1570, 1305, 15, 4443, 272, 862, 26, 489, 340, 892, 63, 1328, 1988, 17, 1055, 1913, 342, 1137, 10812, 267, 892, 63, 1328, 14, 740, 10804, 272, 871, 7888, 26, 489, 986, 339, 892, 63, 1328, 14, 740, 8, 277, 423, 1002, 5083, 8, 4835, 17, 430, 272, 372, 1867, 78, 1674, 904, 8, 1222, 63, 1328, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cfjhallgren/shogun
examples/undocumented/python/transfer_multitask_l12_logistic_regression.py
6
1397
#!/usr/bin/env python from numpy import array,hstack from numpy.random import seed, rand from tools.load import LoadMatrix lm=LoadMatrix() traindat = lm.load_numbers('../data/fm_train_real.dat') testdat = lm.load_numbers('../data/fm_test_real.dat') label_traindat = lm.load_labels('../data/label_train_twoclass.dat') parameter_list = [[traindat,testdat,label_traindat]] def transfer_multitask_l12_logistic_regression (fm_train=traindat,fm_test=testdat,label_train=label_traindat): from shogun import BinaryLabels, RealFeatures, Task, TaskGroup try: from shogun import MultitaskL12LogisticRegression except ImportError: print("MultitaskL12LogisticRegression not available") exit(0) features = RealFeatures(hstack((traindat,traindat))) labels = BinaryLabels(hstack((label_train,label_train))) n_vectors = features.get_num_vectors() task_one = Task(0,n_vectors//2) task_two = Task(n_vectors//2,n_vectors) task_group = TaskGroup() task_group.append_task(task_one) task_group.append_task(task_two) mtlr = MultitaskL12LogisticRegression(0.1,0.1,features,labels,task_group) mtlr.set_tolerance(1e-2) # use 1e-2 tolerance mtlr.set_max_iter(10) mtlr.train() mtlr.set_current_task(0) out = mtlr.apply_regression().get_labels() return out if __name__=='__main__': print('TransferMultitaskL12LogisticRegression') transfer_multitask_l12_logistic_regression(*parameter_list[0])
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 2680, 492, 1625, 12, 20949, 199, 504, 2680, 14, 2355, 492, 6347, 12, 10261, 199, 504, 7249, 14, 912, 492, 7190, 6443, 199, 14344, 29, 6200, 6443, 342, 199, 199, 1239, 688, 292, 275, 24546, 14, 912, 63, 10548, 24592, 576, 15, 10886, 63, 2834, 63, 3093, 14, 4616, 358, 199, 396, 4616, 275, 24546, 14, 912, 63, 10548, 24592, 576, 15, 10886, 63, 396, 63, 3093, 14, 4616, 358, 199, 1302, 63, 1239, 688, 292, 275, 24546, 14, 912, 63, 3512, 24592, 576, 15, 1302, 63, 2834, 63, 5601, 533, 14, 4616, 358, 199, 199, 5329, 63, 513, 275, 3474, 1239, 688, 292, 12, 396, 4616, 12, 1302, 63, 1239, 688, 292, 2677, 199, 199, 318, 9307, 63, 3029, 1765, 63, 76, 713, 63, 23452, 63, 12513, 334, 10886, 63, 2834, 29, 1239, 688, 292, 12, 10886, 63, 396, 29, 396, 4616, 12, 1302, 63, 2834, 29, 1302, 63, 1239, 688, 292, 304, 199, 198, 504, 930, 17924, 492, 14161, 14016, 12, 14849, 10807, 12, 8495, 12, 8495, 2448, 199, 198, 893, 26, 507, 198, 504, 930, 17924, 492, 6879, 1765, 44, 713, 2445, 23032, 199, 198, 2590, 3545, 26, 507, 198, 1361, 480, 3947, 1765, 44, 713, 2445, 23032, 440, 2808, 531, 507, 198, 2224, 8, 16, 9, 421, 198, 3179, 275, 14849, 10807, 8, 20949, 1332, 1239, 688, 292, 12, 1239, 688, 292, 1724, 199, 198, 3512, 275, 14161, 14016, 8, 20949, 1332, 1302, 63, 2834, 12, 1302, 63, 2834, 1724, 421, 198, 78, 63, 12280, 275, 4534, 14, 362, 63, 1507, 63, 12280, 342, 199, 198, 1765, 63, 368, 275, 8495, 8, 16, 12, 78, 63, 12280, 501, 18, 9, 199, 198, 1765, 63, 5601, 275, 8495, 8, 78, 63, 12280, 501, 18, 12, 78, 63, 12280, 9, 199, 198, 1765, 63, 923, 275, 8495, 2448, 342, 199, 198, 1765, 63, 923, 14, 740, 63, 1765, 8, 1765, 63, 368, 9, 199, 198, 1765, 63, 923, 14, 740, 63, 1765, 8, 1765, 63, 5601, 9, 421, 198, 2037, 7493, 275, 6879, 1765, 44, 713, 2445, 23032, 8, 16, 14, 17, 12, 16, 14, 17, 12, 3179, 12, 3512, 12, 1765, 63, 923, 9, 199, 198, 2037, 7493, 14, 409, 63, 16312, 8, 17, 69, 13, 18, 9, 327, 675, 413, 69, 13, 18, 13464, 199, 198, 2037, 7493, 14, 409, 63, 988, 63, 1661, 8, 709, 9, 199, 198, 2037, 7493, 14, 2834, 342, 199, 198, 2037, 7493, 14, 409, 63, 1818, 63, 1765, 8, 16, 9, 199, 198, 548, 275, 333, 5019, 82, 14, 4998, 63, 12513, 1252, 362, 63, 3512, 342, 421, 198, 1107, 734, 199, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 199, 198, 1361, 360, 11761, 3947, 1765, 44, 713, 2445, 23032, 358, 199, 198, 9609, 63, 3029, 1765, 63, 76, 713, 63, 23452, 63, 12513, 2031, 5329, 63, 513, 59, 16, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 2680, 492, 1625, 12, 20949, 199, 504, 2680, 14, 2355, 492, 6347, 12, 10261, 199, 504, 7249, 14, 912, 492, 7190, 6443, 199, 14344, 29, 6200, 6443, 342, 199, 199, 1239, 688, 292, 275, 24546, 14, 912, 63, 10548, 24592, 576, 15, 10886, 63, 2834, 63, 3093, 14, 4616, 358, 199, 396, 4616, 275, 24546, 14, 912, 63, 10548, 24592, 576, 15, 10886, 63, 396, 63, 3093, 14, 4616, 358, 199, 1302, 63, 1239, 688, 292, 275, 24546, 14, 912, 63, 3512, 24592, 576, 15, 1302, 63, 2834, 63, 5601, 533, 14, 4616, 358, 199, 199, 5329, 63, 513, 275, 3474, 1239, 688, 292, 12, 396, 4616, 12, 1302, 63, 1239, 688, 292, 2677, 199, 199, 318, 9307, 63, 3029, 1765, 63, 76, 713, 63, 23452, 63, 12513, 334, 10886, 63, 2834, 29, 1239, 688, 292, 12, 10886, 63, 396, 29, 396, 4616, 12, 1302, 63, 2834, 29, 1302, 63, 1239, 688, 292, 304, 199, 198, 504, 930, 17924, 492, 14161, 14016, 12, 14849, 10807, 12, 8495, 12, 8495, 2448, 199, 198, 893, 26, 507, 198, 504, 930, 17924, 492, 6879, 1765, 44, 713, 2445, 23032, 199, 198, 2590, 3545, 26, 507, 198, 1361, 480, 3947, 1765, 44, 713, 2445, 23032, 440, 2808, 531, 507, 198, 2224, 8, 16, 9, 421, 198, 3179, 275, 14849, 10807, 8, 20949, 1332, 1239, 688, 292, 12, 1239, 688, 292, 1724, 199, 198, 3512, 275, 14161, 14016, 8, 20949, 1332, 1302, 63, 2834, 12, 1302, 63, 2834, 1724, 421, 198, 78, 63, 12280, 275, 4534, 14, 362, 63, 1507, 63, 12280, 342, 199, 198, 1765, 63, 368, 275, 8495, 8, 16, 12, 78, 63, 12280, 501, 18, 9, 199, 198, 1765, 63, 5601, 275, 8495, 8, 78, 63, 12280, 501, 18, 12, 78, 63, 12280, 9, 199, 198, 1765, 63, 923, 275, 8495, 2448, 342, 199, 198, 1765, 63, 923, 14, 740, 63, 1765, 8, 1765, 63, 368, 9, 199, 198, 1765, 63, 923, 14, 740, 63, 1765, 8, 1765, 63, 5601, 9, 421, 198, 2037, 7493, 275, 6879, 1765, 44, 713, 2445, 23032, 8, 16, 14, 17, 12, 16, 14, 17, 12, 3179, 12, 3512, 12, 1765, 63, 923, 9, 199, 198, 2037, 7493, 14, 409, 63, 16312, 8, 17, 69, 13, 18, 9, 327, 675, 413, 69, 13, 18, 13464, 199, 198, 2037, 7493, 14, 409, 63, 988, 63, 1661, 8, 709, 9, 199, 198, 2037, 7493, 14, 2834, 342, 199, 198, 2037, 7493, 14, 409, 63, 1818, 63, 1765, 8, 16, 9, 199, 198, 548, 275, 333, 5019, 82, 14, 4998, 63, 12513, 1252, 362, 63, 3512, 342, 421, 198, 1107, 734, 199, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 199, 198, 1361, 360, 11761, 3947, 1765, 44, 713, 2445, 23032, 358, 199, 198, 9609, 63, 3029, 1765, 63, 76, 713, 63, 23452, 63, 12513, 2031, 5329, 63, 513, 59, 16, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP874.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='cp874', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> NULL u'\x01' # 0x01 -> START OF HEADING u'\x02' # 0x02 -> START OF TEXT u'\x03' # 0x03 -> END OF TEXT u'\x04' # 0x04 -> END OF TRANSMISSION u'\x05' # 0x05 -> ENQUIRY u'\x06' # 0x06 -> ACKNOWLEDGE u'\x07' # 0x07 -> BELL u'\x08' # 0x08 -> BACKSPACE u'\t' # 0x09 -> HORIZONTAL TABULATION u'\n' # 0x0A -> LINE FEED u'\x0b' # 0x0B -> VERTICAL TABULATION u'\x0c' # 0x0C -> FORM FEED u'\r' # 0x0D -> CARRIAGE RETURN u'\x0e' # 0x0E -> SHIFT OUT u'\x0f' # 0x0F -> SHIFT IN u'\x10' # 0x10 -> DATA LINK ESCAPE u'\x11' # 0x11 -> DEVICE CONTROL ONE u'\x12' # 0x12 -> DEVICE CONTROL TWO u'\x13' # 0x13 -> DEVICE CONTROL THREE u'\x14' # 0x14 -> DEVICE CONTROL FOUR u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x16 -> SYNCHRONOUS IDLE u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK u'\x18' # 0x18 -> CANCEL u'\x19' # 0x19 -> END OF MEDIUM u'\x1a' # 0x1A -> SUBSTITUTE u'\x1b' # 0x1B -> ESCAPE u'\x1c' # 0x1C -> FILE SEPARATOR u'\x1d' # 0x1D -> GROUP SEPARATOR u'\x1e' # 0x1E -> RECORD SEPARATOR u'\x1f' # 0x1F -> UNIT SEPARATOR u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> DELETE u'\u20ac' # 0x80 -> EURO SIGN u'\ufffe' # 0x81 -> UNDEFINED u'\ufffe' # 0x82 -> UNDEFINED u'\ufffe' # 0x83 -> UNDEFINED u'\ufffe' # 0x84 -> UNDEFINED u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS u'\ufffe' # 0x86 -> UNDEFINED u'\ufffe' # 0x87 -> UNDEFINED u'\ufffe' # 0x88 -> UNDEFINED u'\ufffe' # 0x89 -> UNDEFINED u'\ufffe' # 0x8A -> UNDEFINED u'\ufffe' # 0x8B -> UNDEFINED u'\ufffe' # 0x8C -> UNDEFINED u'\ufffe' # 0x8D -> UNDEFINED u'\ufffe' # 0x8E -> UNDEFINED u'\ufffe' # 0x8F -> UNDEFINED u'\ufffe' # 0x90 -> UNDEFINED u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK u'\u2022' # 0x95 -> BULLET u'\u2013' # 0x96 -> EN DASH u'\u2014' # 0x97 -> EM DASH u'\ufffe' # 0x98 -> UNDEFINED u'\ufffe' # 0x99 -> UNDEFINED u'\ufffe' # 0x9A -> UNDEFINED u'\ufffe' # 0x9B -> UNDEFINED u'\ufffe' # 0x9C -> UNDEFINED u'\ufffe' # 0x9D -> UNDEFINED u'\ufffe' # 0x9E -> UNDEFINED u'\ufffe' # 0x9F -> UNDEFINED u'\xa0' # 0xA0 -> NO-BREAK SPACE u'\u0e01' # 0xA1 -> THAI CHARACTER KO KAI u'\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI u'\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT u'\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI u'\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON u'\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG u'\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU u'\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN u'\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING u'\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG u'\u0e0b' # 0xAB -> THAI CHARACTER SO SO u'\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE u'\u0e0d' # 0xAD -> THAI CHARACTER YO YING u'\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA u'\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK u'\u0e10' # 0xB0 -> THAI CHARACTER THO THAN u'\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO u'\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO u'\u0e13' # 0xB3 -> THAI CHARACTER NO NEN u'\u0e14' # 0xB4 -> THAI CHARACTER DO DEK u'\u0e15' # 0xB5 -> THAI CHARACTER TO TAO u'\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG u'\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN u'\u0e18' # 0xB8 -> THAI CHARACTER THO THONG u'\u0e19' # 0xB9 -> THAI CHARACTER NO NU u'\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI u'\u0e1b' # 0xBB -> THAI CHARACTER PO PLA u'\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG u'\u0e1d' # 0xBD -> THAI CHARACTER FO FA u'\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN u'\u0e1f' # 0xBF -> THAI CHARACTER FO FAN u'\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO u'\u0e21' # 0xC1 -> THAI CHARACTER MO MA u'\u0e22' # 0xC2 -> THAI CHARACTER YO YAK u'\u0e23' # 0xC3 -> THAI CHARACTER RO RUA u'\u0e24' # 0xC4 -> THAI CHARACTER RU u'\u0e25' # 0xC5 -> THAI CHARACTER LO LING u'\u0e26' # 0xC6 -> THAI CHARACTER LU u'\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN u'\u0e28' # 0xC8 -> THAI CHARACTER SO SALA u'\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI u'\u0e2a' # 0xCA -> THAI CHARACTER SO SUA u'\u0e2b' # 0xCB -> THAI CHARACTER HO HIP u'\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA u'\u0e2d' # 0xCD -> THAI CHARACTER O ANG u'\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK u'\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI u'\u0e30' # 0xD0 -> THAI CHARACTER SARA A u'\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT u'\u0e32' # 0xD2 -> THAI CHARACTER SARA AA u'\u0e33' # 0xD3 -> THAI CHARACTER SARA AM u'\u0e34' # 0xD4 -> THAI CHARACTER SARA I u'\u0e35' # 0xD5 -> THAI CHARACTER SARA II u'\u0e36' # 0xD6 -> THAI CHARACTER SARA UE u'\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE u'\u0e38' # 0xD8 -> THAI CHARACTER SARA U u'\u0e39' # 0xD9 -> THAI CHARACTER SARA UU u'\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU u'\ufffe' # 0xDB -> UNDEFINED u'\ufffe' # 0xDC -> UNDEFINED u'\ufffe' # 0xDD -> UNDEFINED u'\ufffe' # 0xDE -> UNDEFINED u'\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT u'\u0e40' # 0xE0 -> THAI CHARACTER SARA E u'\u0e41' # 0xE1 -> THAI CHARACTER SARA AE u'\u0e42' # 0xE2 -> THAI CHARACTER SARA O u'\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN u'\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI u'\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO u'\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK u'\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU u'\u0e48' # 0xE8 -> THAI CHARACTER MAI EK u'\u0e49' # 0xE9 -> THAI CHARACTER MAI THO u'\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI u'\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA u'\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT u'\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT u'\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN u'\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN u'\u0e50' # 0xF0 -> THAI DIGIT ZERO u'\u0e51' # 0xF1 -> THAI DIGIT ONE u'\u0e52' # 0xF2 -> THAI DIGIT TWO u'\u0e53' # 0xF3 -> THAI DIGIT THREE u'\u0e54' # 0xF4 -> THAI DIGIT FOUR u'\u0e55' # 0xF5 -> THAI DIGIT FIVE u'\u0e56' # 0xF6 -> THAI DIGIT SIX u'\u0e57' # 0xF7 -> THAI DIGIT SEVEN u'\u0e58' # 0xF8 -> THAI DIGIT EIGHT u'\u0e59' # 0xF9 -> THAI DIGIT NINE u'\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU u'\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT u'\ufffe' # 0xFC -> UNDEFINED u'\ufffe' # 0xFD -> UNDEFINED u'\ufffe' # 0xFE -> UNDEFINED u'\ufffe' # 0xFF -> UNDEFINED ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
bsd-2-clause
[ 624, 2018, 17660, 12340, 13732, 7667, 28664, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 17233, 51, 2161, 15, 20509, 15, 2890, 28664, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 1850, 28664, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327 ]
[ 2018, 17660, 12340, 13732, 7667, 28664, 4046, 687, 283, 32362, 15, 27839, 4149, 15, 17233, 51, 2161, 15, 20509, 15, 2890, 28664, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 199, 199, 624, 23662, 199, 199, 646, 6010, 199, 199, 5680, 13732, 15913, 199, 199, 533, 13732, 8, 8933, 14, 8818, 304, 339, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 339, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 199, 199, 533, 24350, 8, 8933, 14, 17016, 304, 272, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 1850, 28664, 297, 267, 3752, 29, 8818, 1252, 2143, 12, 267, 4849, 29, 8818, 1252, 2708, 12, 267, 26329, 29, 17016, 12, 267, 26317, 29, 16703, 12, 267, 26101, 29, 16132, 12, 267, 26112, 29, 16551, 12, 272, 776, 421, 199, 5680, 27368, 6957, 199, 199, 12796, 63, 1224, 275, 334, 272, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 272, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 272, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 272, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 272, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 272, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 272, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 272, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 272, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 272, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 272, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 272, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 272, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 272, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 272, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 272, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 272, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 272, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 272, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 272, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 272, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 272, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 272, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 272, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 272, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 272, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 272, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 272, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 272, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 272, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 272, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 272, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 272, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 272, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 272, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 272, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 272, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 272, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 272, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 272, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 272, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 272, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 272, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 272, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 272, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 272, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 272, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 272, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 272, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 272, 399, 7, 17, 7, 263, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mdsafwan/Deal-My-Stuff
Lib/site-packages/django/templatetags/static.py
250
4055
from django import template from django.utils.encoding import iri_to_uri from django.utils.six.moves.urllib.parse import urljoin register = template.Library() class PrefixNode(template.Node): def __repr__(self): return "<PrefixNode for %r>" % self.name def __init__(self, varname=None, name=None): if name is None: raise template.TemplateSyntaxError( "Prefix nodes must be given a name to return.") self.varname = varname self.name = name @classmethod def handle_token(cls, parser, token, name): """ Class method to parse prefix node and return a Node. """ # token.split_contents() isn't useful here because tags using this method don't accept variable as arguments tokens = token.contents.split() if len(tokens) > 1 and tokens[1] != 'as': raise template.TemplateSyntaxError( "First argument in '%s' must be 'as'" % tokens[0]) if len(tokens) > 1: varname = tokens[2] else: varname = None return cls(varname, name) @classmethod def handle_simple(cls, name): try: from django.conf import settings except ImportError: prefix = '' else: prefix = iri_to_uri(getattr(settings, name, '')) return prefix def render(self, context): prefix = self.handle_simple(self.name) if self.varname is None: return prefix context[self.varname] = prefix return '' @register.tag def get_static_prefix(parser, token): """ Populates a template variable with the static prefix, ``settings.STATIC_URL``. Usage:: {% get_static_prefix [as varname] %} Examples:: {% get_static_prefix %} {% get_static_prefix as static_prefix %} """ return PrefixNode.handle_token(parser, token, "STATIC_URL") @register.tag def get_media_prefix(parser, token): """ Populates a template variable with the media prefix, ``settings.MEDIA_URL``. Usage:: {% get_media_prefix [as varname] %} Examples:: {% get_media_prefix %} {% get_media_prefix as media_prefix %} """ return PrefixNode.handle_token(parser, token, "MEDIA_URL") class StaticNode(template.Node): def __init__(self, varname=None, path=None): if path is None: raise template.TemplateSyntaxError( "Static template nodes must be given a path to return.") self.path = path self.varname = varname def url(self, context): path = self.path.resolve(context) return self.handle_simple(path) def render(self, context): url = self.url(context) if self.varname is None: return url context[self.varname] = url return '' @classmethod def handle_simple(cls, path): return urljoin(PrefixNode.handle_simple("STATIC_URL"), path) @classmethod def handle_token(cls, parser, token): """ Class method to parse prefix node and return a Node. """ bits = token.split_contents() if len(bits) < 2: raise template.TemplateSyntaxError( "'%s' takes at least one argument (path to file)" % bits[0]) path = parser.compile_filter(bits[1]) if len(bits) >= 2 and bits[-2] == 'as': varname = bits[3] else: varname = None return cls(varname, path) @register.tag('static') def do_static(parser, token): """ Joins the given path with the STATIC_URL setting. Usage:: {% static path [as varname] %} Examples:: {% static "myapp/css/base.css" %} {% static variable_with_path %} {% static "myapp/css/base.css" as admin_base_css %} {% static variable_with_path as varname %} """ return StaticNode.handle_token(parser, token) def static(path): return StaticNode.handle_simple(path)
apache-2.0
[ 504, 1639, 492, 1978, 199, 504, 1639, 14, 1208, 14, 2991, 492, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 20818, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 533, 25110, 1716, 8, 1160, 14, 1716, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 4793, 1716, 367, 450, 82, 4335, 450, 291, 14, 354, 339, 347, 636, 826, 721, 277, 12, 22071, 29, 403, 12, 536, 29, 403, 304, 267, 340, 536, 365, 488, 26, 288, 746, 1978, 14, 20837, 8, 355, 298, 4793, 3380, 1471, 506, 1627, 282, 536, 370, 372, 2685, 267, 291, 14, 16043, 275, 22071, 267, 291, 14, 354, 275, 536, 339, 768, 3744, 272, 347, 2429, 63, 1418, 8, 1886, 12, 1798, 12, 1526, 12, 536, 304, 267, 408, 267, 8089, 1083, 370, 2198, 2403, 1031, 436, 372, 282, 5013, 14, 267, 408, 267, 327, 1526, 14, 1294, 63, 4407, 342, 5712, 1133, 2997, 2348, 2952, 3762, 1808, 642, 1083, 2793, 1133, 4729, 1750, 465, 2368, 267, 4645, 275, 1526, 14, 4407, 14, 1294, 342, 267, 340, 822, 8, 4504, 9, 690, 413, 436, 4645, 59, 17, 61, 1137, 283, 305, 356, 288, 746, 1978, 14, 20837, 8, 355, 298, 7147, 1423, 315, 1543, 83, 7, 1471, 506, 283, 305, 4065, 450, 4645, 59, 16, 566, 267, 340, 822, 8, 4504, 9, 690, 413, 26, 288, 22071, 275, 4645, 59, 18, 61, 267, 587, 26, 288, 22071, 275, 488, 267, 372, 843, 8, 16043, 12, 536, 9, 339, 768, 3744, 272, 347, 2429, 63, 4129, 8, 1886, 12, 536, 304, 267, 862, 26, 288, 687, 1639, 14, 2190, 492, 2202, 267, 871, 3545, 26, 288, 2403, 275, 2125, 267, 587, 26, 288, 2403, 275, 24086, 63, 475, 63, 2302, 8, 5675, 8, 1751, 12, 536, 12, 12381, 267, 372, 2403, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 2403, 275, 291, 14, 2479, 63, 4129, 8, 277, 14, 354, 9, 267, 340, 291, 14, 16043, 365, 488, 26, 288, 372, 2403, 267, 1067, 59, 277, 14, 16043, 61, 275, 2403, 267, 372, 2125, 421, 199, 32, 2683, 14, 1450, 199, 318, 664, 63, 1986, 63, 1861, 8, 2087, 12, 1526, 304, 272, 408, 272, 13244, 15409, 282, 1978, 1750, 543, 314, 2955, 2403, 12, 272, 1124, 1751, 14, 10449, 63, 2632, 4345, 339, 11028, 447, 398, 7749, 664, 63, 1986, 63, 1861, 359, 305, 22071, 61, 3674, 339, 6058, 447, 398, 7749, 664, 63, 1986, 63, 1861, 3674, 267, 7749, 664, 63, 1986, 63, 1861, 465, 2955, 63, 1861, 3674, 339, 408, 272, 372, 25110, 1716, 14, 2479, 63, 1418, 8, 2087, 12, 1526, 12, 298, 10449, 63, 2632, 531, 421, 199, 32, 2683, 14, 1450, 199, 318, 664, 63, 4603, 63, 1861, 8, 2087, 12, 1526, 304, 272, 408, 272, 13244, 15409, 282, 1978, 1750, 543, 314, 5898, 2403, 12, 272, 1124, 1751, 14, 13669, 63, 2632, 4345, 339, 11028, 447, 398, 7749, 664, 63, 4603, 63, 1861, 359, 305, 22071, 61, 3674, 339, 6058, 447, 398, 7749, 664, 63, 4603, 63, 1861, 3674, 267, 7749, 664, 63, 4603, 63, 1861, 465, 5898, 63, 1861, 3674, 339, 408, 272, 372, 25110, 1716, 14, 2479, 63, 1418, 8, 2087, 12, 1526, 12, 298, 13669, 63, 2632, 531, 421, 199, 533, 13599, 1716, 8, 1160, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 22071, 29, 403, 12, 931, 29, 403, 304, 267, 340, 931, 365, 488, 26, 288, 746, 1978, 14, 20837, 8, 355, 298, 9278, 1978, 3380, 1471, 506, 1627, 282, 931, 370, 372, 2685, 267, 291, 14, 515, 275, 931, 267, 291, 14, 16043, 275, 22071, 339, 347, 1166, 8, 277, 12, 1067, 304, 267, 931, 275, 291, 14, 515, 14, 6983, 8, 1100, 9, 267, 372, 291, 14, 2479, 63, 4129, 8, 515, 9, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 1166, 275, 291, 14, 633, 8, 1100, 9, 267, 340, 291, 14, 16043, 365, 488, 26, 288, 372, 1166, 267, 1067, 59, 277, 14, 16043, 61, 275, 1166, 267, 372, 2125, 339, 768, 3744, 272, 347, 2429, 63, 4129, 8, 1886, 12, 931, 304, 267, 372, 20818, 8, 4793, 1716, 14, 2479, 63, 4129, 480, 10449, 63, 2632, 1288, 931, 9, 339, 768, 3744, 272, 347, 2429, 63, 1418, 8, 1886, 12, 1798, 12, 1526, 304, 267, 408, 267, 8089, 1083, 370, 2198, 2403, 1031, 436, 372, 282, 5013, 14, 267, 408, 267, 5821, 275, 1526, 14, 1294, 63, 4407, 342, 398, 340, 822, 8, 5609, 9, 665, 499, 26, 288, 746, 1978, 14, 20837, 8, 355, 17648, 83, 7, 6181, 737, 5210, 1373, 1423, 334, 515, 370, 570, 2924, 450, 5821, 59, 16, 566, 398, 931, 275, 1798, 14, 2014, 63, 1541, 8, 5609, 59, 17, 566, 398, 340, 822, 8, 5609, 9, 2356, 499, 436, 5821, 1988, 18, 61, 508, 283, 305, 356, 288, 22071, 275, 5821, 59, 19, 61, 267, 587, 26, 288, 22071, 275, 488, 398, 372, 843, 8, 16043, 12, 931, 9, 421, 199, 32, 2683, 14, 1450, 360, 1986, 358, 199, 318, 886, 63, 1986, 8, 2087, 12, 1526, 304, 272, 408, 272, 7135, 3617, 314, 1627, 931, 543, 314, 27815, 63, 2632, 4260, 14, 339, 11028, 447, 398, 7749, 2955, 931, 359, 305, 22071, 61, 3674, 339, 6058, 447, 398, 7749, 2955, 298, 1662, 571, 15, 3919, 15, 1095, 14, 3919, 2, 3674, 267, 7749, 2955, 1750, 63, 1045, 63, 515, 3674, 267, 7749, 2955, 298, 1662, 571, 15, 3919, 15, 1095, 14, 3919, 2, 465, 4628, 63, 1095, 63, 3919, 3674, 267, 7749, 2955, 1750, 63, 1045, 63, 515, 465, 22071, 3674, 339, 408, 272, 372, 13599, 1716, 14, 2479, 63, 1418, 8, 2087, 12, 1526, 9, 421, 199, 318, 2955, 8, 515, 304, 272, 372, 13599, 1716, 14, 2479, 63, 4129, 8, 515, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 492, 1978, 199, 504, 1639, 14, 1208, 14, 2991, 492, 24086, 63, 475, 63, 2302, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 14, 4078, 14, 1122, 492, 20818, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 533, 25110, 1716, 8, 1160, 14, 1716, 304, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 4793, 1716, 367, 450, 82, 4335, 450, 291, 14, 354, 339, 347, 636, 826, 721, 277, 12, 22071, 29, 403, 12, 536, 29, 403, 304, 267, 340, 536, 365, 488, 26, 288, 746, 1978, 14, 20837, 8, 355, 298, 4793, 3380, 1471, 506, 1627, 282, 536, 370, 372, 2685, 267, 291, 14, 16043, 275, 22071, 267, 291, 14, 354, 275, 536, 339, 768, 3744, 272, 347, 2429, 63, 1418, 8, 1886, 12, 1798, 12, 1526, 12, 536, 304, 267, 408, 267, 8089, 1083, 370, 2198, 2403, 1031, 436, 372, 282, 5013, 14, 267, 408, 267, 327, 1526, 14, 1294, 63, 4407, 342, 5712, 1133, 2997, 2348, 2952, 3762, 1808, 642, 1083, 2793, 1133, 4729, 1750, 465, 2368, 267, 4645, 275, 1526, 14, 4407, 14, 1294, 342, 267, 340, 822, 8, 4504, 9, 690, 413, 436, 4645, 59, 17, 61, 1137, 283, 305, 356, 288, 746, 1978, 14, 20837, 8, 355, 298, 7147, 1423, 315, 1543, 83, 7, 1471, 506, 283, 305, 4065, 450, 4645, 59, 16, 566, 267, 340, 822, 8, 4504, 9, 690, 413, 26, 288, 22071, 275, 4645, 59, 18, 61, 267, 587, 26, 288, 22071, 275, 488, 267, 372, 843, 8, 16043, 12, 536, 9, 339, 768, 3744, 272, 347, 2429, 63, 4129, 8, 1886, 12, 536, 304, 267, 862, 26, 288, 687, 1639, 14, 2190, 492, 2202, 267, 871, 3545, 26, 288, 2403, 275, 2125, 267, 587, 26, 288, 2403, 275, 24086, 63, 475, 63, 2302, 8, 5675, 8, 1751, 12, 536, 12, 12381, 267, 372, 2403, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 2403, 275, 291, 14, 2479, 63, 4129, 8, 277, 14, 354, 9, 267, 340, 291, 14, 16043, 365, 488, 26, 288, 372, 2403, 267, 1067, 59, 277, 14, 16043, 61, 275, 2403, 267, 372, 2125, 421, 199, 32, 2683, 14, 1450, 199, 318, 664, 63, 1986, 63, 1861, 8, 2087, 12, 1526, 304, 272, 408, 272, 13244, 15409, 282, 1978, 1750, 543, 314, 2955, 2403, 12, 272, 1124, 1751, 14, 10449, 63, 2632, 4345, 339, 11028, 447, 398, 7749, 664, 63, 1986, 63, 1861, 359, 305, 22071, 61, 3674, 339, 6058, 447, 398, 7749, 664, 63, 1986, 63, 1861, 3674, 267, 7749, 664, 63, 1986, 63, 1861, 465, 2955, 63, 1861, 3674, 339, 408, 272, 372, 25110, 1716, 14, 2479, 63, 1418, 8, 2087, 12, 1526, 12, 298, 10449, 63, 2632, 531, 421, 199, 32, 2683, 14, 1450, 199, 318, 664, 63, 4603, 63, 1861, 8, 2087, 12, 1526, 304, 272, 408, 272, 13244, 15409, 282, 1978, 1750, 543, 314, 5898, 2403, 12, 272, 1124, 1751, 14, 13669, 63, 2632, 4345, 339, 11028, 447, 398, 7749, 664, 63, 4603, 63, 1861, 359, 305, 22071, 61, 3674, 339, 6058, 447, 398, 7749, 664, 63, 4603, 63, 1861, 3674, 267, 7749, 664, 63, 4603, 63, 1861, 465, 5898, 63, 1861, 3674, 339, 408, 272, 372, 25110, 1716, 14, 2479, 63, 1418, 8, 2087, 12, 1526, 12, 298, 13669, 63, 2632, 531, 421, 199, 533, 13599, 1716, 8, 1160, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 22071, 29, 403, 12, 931, 29, 403, 304, 267, 340, 931, 365, 488, 26, 288, 746, 1978, 14, 20837, 8, 355, 298, 9278, 1978, 3380, 1471, 506, 1627, 282, 931, 370, 372, 2685, 267, 291, 14, 515, 275, 931, 267, 291, 14, 16043, 275, 22071, 339, 347, 1166, 8, 277, 12, 1067, 304, 267, 931, 275, 291, 14, 515, 14, 6983, 8, 1100, 9, 267, 372, 291, 14, 2479, 63, 4129, 8, 515, 9, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 1166, 275, 291, 14, 633, 8, 1100, 9, 267, 340, 291, 14, 16043, 365, 488, 26, 288, 372, 1166, 267, 1067, 59, 277, 14, 16043, 61, 275, 1166, 267, 372, 2125, 339, 768, 3744, 272, 347, 2429, 63, 4129, 8, 1886, 12, 931, 304, 267, 372, 20818, 8, 4793, 1716, 14, 2479, 63, 4129, 480, 10449, 63, 2632, 1288, 931, 9, 339, 768, 3744, 272, 347, 2429, 63, 1418, 8, 1886, 12, 1798, 12, 1526, 304, 267, 408, 267, 8089, 1083, 370, 2198, 2403, 1031, 436, 372, 282, 5013, 14, 267, 408, 267, 5821, 275, 1526, 14, 1294, 63, 4407, 342, 398, 340, 822, 8, 5609, 9, 665, 499, 26, 288, 746, 1978, 14, 20837, 8, 355, 17648, 83, 7, 6181, 737, 5210, 1373, 1423, 334, 515, 370, 570, 2924, 450, 5821, 59, 16, 566, 398, 931, 275, 1798, 14, 2014, 63, 1541, 8, 5609, 59, 17, 566, 398, 340, 822, 8, 5609, 9, 2356, 499, 436, 5821, 1988, 18, 61, 508, 283, 305, 356, 288, 22071, 275, 5821, 59, 19, 61, 267, 587, 26, 288, 22071, 275, 488, 398, 372, 843, 8, 16043, 12, 931, 9, 421, 199, 32, 2683, 14, 1450, 360, 1986, 358, 199, 318, 886, 63, 1986, 8, 2087, 12, 1526, 304, 272, 408, 272, 7135, 3617, 314, 1627, 931, 543, 314, 27815, 63, 2632, 4260, 14, 339, 11028, 447, 398, 7749, 2955, 931, 359, 305, 22071, 61, 3674, 339, 6058, 447, 398, 7749, 2955, 298, 1662, 571, 15, 3919, 15, 1095, 14, 3919, 2, 3674, 267, 7749, 2955, 1750, 63, 1045, 63, 515, 3674, 267, 7749, 2955, 298, 1662, 571, 15, 3919, 15, 1095, 14, 3919, 2, 465, 4628, 63, 1095, 63, 3919, 3674, 267, 7749, 2955, 1750, 63, 1045, 63, 515, 465, 22071, 3674, 339, 408, 272, 372, 13599, 1716, 14, 2479, 63, 1418, 8, 2087, 12, 1526, 9, 421, 199, 318, 2955, 8, 515, 304, 272, 372, 13599, 1716, 14, 2479, 63, 4129, 8, 515, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aldian/tensorflow
tensorflow/contrib/boosted_trees/python/kernel_tests/training_ops_test.py
13
52856
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for the GTFlow training Ops.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from google.protobuf import text_format from tensorflow.contrib.boosted_trees.proto import learner_pb2 from tensorflow.contrib.boosted_trees.proto import split_info_pb2 from tensorflow.contrib.boosted_trees.proto import tree_config_pb2 from tensorflow.contrib.boosted_trees.python.ops import model_ops from tensorflow.contrib.boosted_trees.python.ops import training_ops from tensorflow.python.framework import constant_op from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import resources from tensorflow.python.platform import googletest def _gen_learner_config(num_classes, l1_reg, l2_reg, tree_complexity, max_depth, min_node_weight, pruning_mode, growing_mode, dropout_probability=None, dropout_learning_rate=None, dropout_prob_of_skipping=None): """Create a serialized learner config with the desired settings.""" config = learner_pb2.LearnerConfig() config.num_classes = num_classes config.regularization.l1 = l1_reg config.regularization.l2 = l2_reg config.regularization.tree_complexity = tree_complexity config.constraints.max_tree_depth = max_depth config.constraints.min_node_weight = min_node_weight config.pruning_mode = pruning_mode config.growing_mode = growing_mode if dropout_probability is not None: config.learning_rate_tuner.dropout.dropout_probability = dropout_probability if dropout_learning_rate is not None: config.learning_rate_tuner.dropout.learning_rate = dropout_learning_rate if dropout_prob_of_skipping is not None: config.learning_rate_tuner.dropout.dropout_prob_of_skipping = ( dropout_prob_of_skipping) return config.SerializeToString() def _gen_dense_split_info(fc, threshold, left_weight, right_weight): split_str = """ split_node { dense_float_binary_split { feature_column: %d threshold: %f } } left_child { sparse_vector { index: 0 value: %f } } right_child { sparse_vector { index: 0 value: %f } }""" % (fc, threshold, left_weight, right_weight) split = split_info_pb2.SplitInfo() text_format.Merge(split_str, split) return split.SerializeToString() def _gen_categorical_split_info(fc, feat_id, left_weight, right_weight): split_str = """ split_node { categorical_id_binary_split { feature_column: %d feature_id: %d } } left_child { sparse_vector { index: 0 value: %f } } right_child { sparse_vector { index: 0 value: %f } }""" % (fc, feat_id, left_weight, right_weight) split = split_info_pb2.SplitInfo() text_format.Merge(split_str, split) return split.SerializeToString() def _get_bias_update(grads, hess): return array_ops.where(hess > 0, -grads / hess, array_ops.zeros_like(grads)) class CenterTreeEnsembleBiasOpTest(test_util.TensorFlowTestCase): """Tests for centering tree ensemble bias.""" def testCenterBias(self): """Tests bias centering for multiple iterations.""" with self.test_session() as session: # Create empty ensemble. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=3, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=4, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE, # Dropout does not change anything here. dropout_probability=0.5) # Center bias for the initial step. grads = constant_op.constant([0.4, -0.3]) hess = constant_op.constant([2.0, 1.0]) continue_centering1 = training_ops.center_tree_ensemble_bias( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, delta_updates=_get_bias_update(grads, hess), learner_config=learner_config) continue_centering = session.run(continue_centering1) self.assertEqual(continue_centering, True) # Validate ensemble state. # dim 0 update: -0.4/2.0 = -0.2 # dim 1 update: +0.3/1.0 = +0.3 new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { leaf { vector { value: -0.2 value: 0.3 } } } } tree_weights: 1.0 tree_metadata { num_layers_grown: 1 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(expected_result, tree_ensemble_config) # Center bias for another step. # dim 0 update: -0.06/0.5 = -0.12 # dim 1 update: -0.01/0.5 = -0.02 grads = constant_op.constant([0.06, 0.01]) hess = constant_op.constant([0.5, 0.5]) continue_centering2 = training_ops.center_tree_ensemble_bias( tree_ensemble_handle, stamp_token=1, next_stamp_token=2, delta_updates=_get_bias_update(grads, hess), learner_config=learner_config) continue_centering = session.run(continue_centering2) self.assertEqual(continue_centering, True) # Validate ensemble state. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=2)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { leaf { vector { value: -0.32 value: 0.28 } } } } tree_weights: 1.0 tree_metadata { num_layers_grown: 1 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """ self.assertEqual(new_stamp, 2) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(expected_result, tree_ensemble_config) # Center bias for another step, but this time updates are negligible. grads = constant_op.constant([0.0000001, -0.00003]) hess = constant_op.constant([0.5, 0.0]) continue_centering3 = training_ops.center_tree_ensemble_bias( tree_ensemble_handle, stamp_token=2, next_stamp_token=3, delta_updates=_get_bias_update(grads, hess), learner_config=learner_config) continue_centering = session.run(continue_centering3) self.assertEqual(continue_centering, False) # Validate ensemble stamp. new_stamp, _ = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=3)) self.assertEqual(new_stamp, 3) self.assertEqual(stats.num_trees, 1) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) class GrowTreeEnsembleOpTest(test_util.TensorFlowTestCase): """Tests for growing tree ensemble from split candidates.""" def testGrowEmptyEnsemble(self): """Test growing an empty ensemble.""" with self.test_session() as session: # Create empty ensemble. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=1, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE, # Dropout does not change anything here, tree is not finalized. dropout_probability=0.5) # Prepare handler inputs. # Note that handlers 1 & 3 have the same gain but different splits. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([7.62], dtype=np.float32) handler1_split = [_gen_dense_split_info(0, 0.52, -4.375, 7.143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([0.63], dtype=np.float32) handler2_split = [_gen_dense_split_info(0, 0.23, -0.6, 0.24)] handler3_partitions = np.array([0], dtype=np.int32) handler3_gains = np.array([7.62], dtype=np.float32) handler3_split = [_gen_categorical_split_info(0, 7, -4.375, 7.143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[ handler1_partitions, handler2_partitions, handler3_partitions ], gains=[handler1_gains, handler2_gains, handler3_gains], splits=[handler1_split, handler2_split, handler3_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the simpler split from handler 1 to be chosen. # The grown tree should be finalized as max tree depth is 1. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { dense_float_binary_split { threshold: 0.52 left_id: 1 right_id: 2 } node_metadata { gain: 7.62 } } nodes { leaf { sparse_vector { index: 0 value: -4.375 } } } nodes { leaf { sparse_vector { index: 0 value: 7.143 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 is_finalized: true } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 1) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(expected_result, tree_ensemble_config) def testGrowExistingEnsembleTreeNotFinalized(self): """Test growing an existing ensemble with the last tree not finalized.""" with self.test_session() as session: # Create existing ensemble with one root split tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() text_format.Merge(""" trees { nodes { categorical_id_binary_split { feature_id: 4 left_id: 1 right_id: 2 } node_metadata { gain: 7.61999988556 } } nodes { leaf { sparse_vector { index: 0 value: 7.14300012589 } } } nodes { leaf { sparse_vector { index: 0 value: -4.375 } } } } tree_weights: 0.10000000149 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """, tree_ensemble_config) tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=3, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE, # Dropout does not change anything here - tree is not finalized. dropout_probability=0.5) # Prepare handler inputs. # Handler 1 only has a candidate for partition 1, handler 2 has candidates # for both partitions and handler 3 only has a candidate for partition 2. handler1_partitions = np.array([1], dtype=np.int32) handler1_gains = np.array([1.4], dtype=np.float32) handler1_split = [_gen_dense_split_info(0, 0.21, -6.0, 1.65)] handler2_partitions = np.array([1, 2], dtype=np.int32) handler2_gains = np.array([0.63, 2.7], dtype=np.float32) handler2_split = [ _gen_dense_split_info(0, 0.23, -0.6, 0.24), _gen_categorical_split_info(1, 7, -1.5, 2.3) ] handler3_partitions = np.array([2], dtype=np.int32) handler3_gains = np.array([1.7], dtype=np.float32) handler3_split = [_gen_categorical_split_info(0, 3, -0.75, 1.93)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[ handler1_partitions, handler2_partitions, handler3_partitions ], gains=[handler1_gains, handler2_gains, handler3_gains], splits=[handler1_split, handler2_split, handler3_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the split for partition 1 to be chosen from handler 1 and # the split for partition 2 to be chosen from handler 2. # The grown tree should not be finalized as max tree depth is 3 and # it's only grown 2 layers. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { categorical_id_binary_split { feature_id: 4 left_id: 1 right_id: 2 } node_metadata { gain: 7.61999988556 } } nodes { dense_float_binary_split { threshold: 0.21 left_id: 3 right_id: 4 } node_metadata { gain: 1.4 } } nodes { categorical_id_binary_split { feature_column: 1 feature_id: 7 left_id: 5 right_id: 6 } node_metadata { gain: 2.7 } } nodes { leaf { sparse_vector { index: 0 value: -6.0 } } } nodes { leaf { sparse_vector { index: 0 value: 1.65 } } } nodes { leaf { sparse_vector { index: 0 value: -1.5 } } } nodes { leaf { sparse_vector { index: 0 value: 2.3 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 2 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 2 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 2) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 2) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 2) self.assertProtoEquals(expected_result, tree_ensemble_config) def testGrowExistingEnsembleTreeFinalized(self): """Test growing an existing ensemble with the last tree finalized.""" with self.test_session() as session: # Create existing ensemble with one root split tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() text_format.Merge(""" trees { nodes { categorical_id_binary_split { feature_column: 3 feature_id: 7 left_id: 1 right_id: 2 } node_metadata { gain: 1.3 } } nodes { leaf { sparse_vector { index: 0 value: 2.3 } } } nodes { leaf { sparse_vector { index: 0 value: -0.9 } } } } tree_weights: 0.10000000149 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 is_finalized: true } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """, tree_ensemble_config) tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=1, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE) # Prepare handler inputs. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([7.62], dtype=np.float32) handler1_split = [_gen_dense_split_info(5, 0.52, -4.375, 7.143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([0.63], dtype=np.float32) handler2_split = [_gen_dense_split_info(2, 0.23, -0.6, 0.24)] handler3_partitions = np.array([0], dtype=np.int32) handler3_gains = np.array([7.62], dtype=np.float32) handler3_split = [_gen_categorical_split_info(8, 7, -4.375, 7.143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.2, partition_ids=[ handler1_partitions, handler2_partitions, handler3_partitions ], gains=[handler1_gains, handler2_gains, handler3_gains], splits=[handler1_split, handler2_split, handler3_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect a new tree to be added with the split from handler 1. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { categorical_id_binary_split { feature_column: 3 feature_id: 7 left_id: 1 right_id: 2 } node_metadata { gain: 1.3 } } nodes { leaf { sparse_vector { index: 0 value: 2.3 } } } nodes { leaf { sparse_vector { index: 0 value: -0.9 } } } } trees { nodes { dense_float_binary_split { feature_column: 5 threshold: 0.52 left_id: 1 right_id: 2 } node_metadata { gain: 7.62 } } nodes { leaf { sparse_vector { index: 0 value: -4.375 } } } nodes { leaf { sparse_vector { index: 0 value: 7.143 } } } } tree_weights: 0.1 tree_weights: 0.2 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 is_finalized: true } tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 is_finalized: true } growing_metadata { num_trees_attempted: 2 num_layers_attempted: 2 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 2) self.assertEqual(stats.num_layers, 2) self.assertEqual(stats.active_tree, 2) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 2) self.assertEqual(stats.attempted_layers, 2) self.assertProtoEquals(expected_result, tree_ensemble_config) def testGrowEnsemblePrePrune(self): """Test growing an ensemble with pre-pruning.""" with self.test_session() as session: # Create empty ensemble. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=1, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE) # Prepare handler inputs. # All handlers have negative gain. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([-0.62], dtype=np.float32) handler1_split = [_gen_dense_split_info(0, 0.52, 0.01, 0.0143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([-1.3], dtype=np.float32) handler2_split = [_gen_categorical_split_info(0, 7, 0.013, 0.0143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[handler1_partitions, handler2_partitions], gains=[handler1_gains, handler2_gains], splits=[handler1_split, handler2_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the ensemble to be empty. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 0) self.assertEqual(stats.active_tree, 0) self.assertEqual(stats.active_layer, 0) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(""" growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """, tree_ensemble_config) def testGrowEnsemblePostPruneNone(self): """Test growing an empty ensemble.""" with self.test_session() as session: # Create empty ensemble. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=1, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.POST_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE) # Prepare handler inputs. # Note that handlers 1 & 3 have the same gain but different splits. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([7.62], dtype=np.float32) handler1_split = [_gen_dense_split_info(0, 0.52, -4.375, 7.143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([0.63], dtype=np.float32) handler2_split = [_gen_dense_split_info(0, 0.23, -0.6, 0.24)] handler3_partitions = np.array([0], dtype=np.int32) handler3_gains = np.array([7.62], dtype=np.float32) handler3_split = [_gen_categorical_split_info(0, 7, -4.375, 7.143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[ handler1_partitions, handler2_partitions, handler3_partitions ], gains=[handler1_gains, handler2_gains, handler3_gains], splits=[handler1_split, handler2_split, handler3_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the simpler split from handler 1 to be chosen. # The grown tree should be finalized as max tree depth is 1. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { dense_float_binary_split { threshold: 0.52 left_id: 1 right_id: 2 } node_metadata { gain: 7.62 } } nodes { leaf { sparse_vector { index: 0 value: -4.375 } } } nodes { leaf { sparse_vector { index: 0 value: 7.143 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 is_finalized: true } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 1) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(expected_result, tree_ensemble_config) def testGrowEnsemblePostPruneAll(self): """Test growing an ensemble with post-pruning.""" with self.test_session() as session: # Create empty ensemble. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=2, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.POST_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE) # Prepare handler inputs. # All handlers have negative gain. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([-1.3], dtype=np.float32) handler1_split = [_gen_categorical_split_info(0, 7, 0.013, 0.0143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([-0.62], dtype=np.float32) handler2_split = [_gen_dense_split_info(0, 0.33, 0.01, 0.0143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[handler1_partitions, handler2_partitions], gains=[handler1_gains, handler2_gains], splits=[handler1_split, handler2_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the split from handler 2 to be chosen despite the negative gain. # The grown tree should not be finalized as max tree depth is 2 so no # pruning occurs. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) tree_ensemble_config.ParseFromString(serialized) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) expected_result = """ trees { nodes { dense_float_binary_split { threshold: 0.33 left_id: 1 right_id: 2 } node_metadata { gain: -0.62 original_leaf { } } } nodes { leaf { sparse_vector { index: 0 value: 0.01 } } } nodes { leaf { sparse_vector { index: 0 value: 0.0143 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(expected_result, tree_ensemble_config) # Prepare handler inputs. # All handlers have negative gain. handler1_partitions = np.array([1, 2], dtype=np.int32) handler1_gains = np.array([-0.2, -0.5], dtype=np.float32) handler1_split = [ _gen_categorical_split_info(3, 7, 0.07, 0.083), _gen_categorical_split_info(3, 5, 0.041, 0.064) ] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=1, next_stamp_token=2, learning_rate=0.1, partition_ids=[handler1_partitions], gains=[handler1_gains], splits=[handler1_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the ensemble to be empty as post-pruning will prune # the entire finalized tree. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=2)) tree_ensemble_config.ParseFromString(serialized) self.assertEqual(new_stamp, 2) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 0) self.assertEqual(stats.active_tree, 0) self.assertEqual(stats.active_layer, 0) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 2) self.assertProtoEquals(""" growing_metadata { num_trees_attempted: 1 num_layers_attempted: 2 } """, tree_ensemble_config) def testGrowEnsemblePostPrunePartial(self): """Test growing an ensemble with post-pruning.""" with self.test_session() as session: # Create empty ensemble. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=2, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.POST_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE) # Prepare handler inputs. # Second handler has positive gain. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([-1.3], dtype=np.float32) handler1_split = [_gen_categorical_split_info(0, 7, 0.013, 0.0143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([-0.2], dtype=np.float32) handler2_split = [_gen_dense_split_info(0, 0.33, 0.01, 0.0143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[handler1_partitions, handler2_partitions], gains=[handler1_gains, handler2_gains], splits=[handler1_split, handler2_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the split from handler 2 to be chosen despite the negative gain. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { dense_float_binary_split { threshold: 0.33 left_id: 1 right_id: 2 } node_metadata { gain: -0.2 original_leaf { } } } nodes { leaf { sparse_vector { index: 0 value: 0.01 } } } nodes { leaf { sparse_vector { index: 0 value: 0.0143 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 1) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 1) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 1) self.assertProtoEquals(expected_result, tree_ensemble_config) # Prepare handler inputs for second layer. # Note that partition 1 gain is negative and partition 2 gain is positive. handler1_partitions = np.array([1, 2], dtype=np.int32) handler1_gains = np.array([-0.2, 0.5], dtype=np.float32) handler1_split = [ _gen_categorical_split_info(3, 7, 0.07, 0.083), _gen_categorical_split_info(3, 5, 0.041, 0.064) ] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=1, next_stamp_token=2, learning_rate=0.1, partition_ids=[handler1_partitions], gains=[handler1_gains], splits=[handler1_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the negative gain split of partition 1 to be pruned and the # positive gain split of partition 2 to be retained. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=2)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { dense_float_binary_split { threshold: 0.33 left_id: 1 right_id: 2 } node_metadata { gain: -0.2 } } nodes { leaf { sparse_vector { index: 0 value: 0.01 } } } nodes { categorical_id_binary_split { feature_column: 3 feature_id: 5 left_id: 3 right_id: 4 } node_metadata { gain: 0.5 } } nodes { leaf { sparse_vector { index: 0 value: 0.041 } } } nodes { leaf { sparse_vector { index: 0 value: 0.064 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 2 is_finalized: true } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 2 } """ self.assertEqual(new_stamp, 2) self.assertEqual(stats.num_trees, 1) self.assertEqual(stats.num_layers, 2) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 2) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 2) self.assertProtoEquals(expected_result, tree_ensemble_config) def testGrowEnsembleTreeLayerByLayer(self): """Test growing an existing ensemble with the last tree not finalized.""" with self.test_session() as session: # Create existing ensemble with one root split tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() text_format.Merge(""" trees { nodes { categorical_id_binary_split { feature_id: 4 left_id: 1 right_id: 2 } node_metadata { gain: 7.62 } } nodes { leaf { sparse_vector { index: 0 value: 7.143 } } } nodes { leaf { sparse_vector { index: 0 value: -4.375 } } } } tree_weights: 0.10000000149 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 1 } """, tree_ensemble_config) tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=3, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.LAYER_BY_LAYER, # Dropout will have no effect, since the tree will not be fully grown. dropout_probability=1.0) # Prepare handler inputs. # Handler 1 only has a candidate for partition 1, handler 2 has candidates # for both partitions and handler 3 only has a candidate for partition 2. handler1_partitions = np.array([1], dtype=np.int32) handler1_gains = np.array([1.4], dtype=np.float32) handler1_split = [_gen_dense_split_info(0, 0.21, -6.0, 1.65)] handler2_partitions = np.array([1, 2], dtype=np.int32) handler2_gains = np.array([0.63, 2.7], dtype=np.float32) handler2_split = [ _gen_dense_split_info(0, 0.23, -0.6, 0.24), _gen_categorical_split_info(1, 7, -1.5, 2.3) ] handler3_partitions = np.array([2], dtype=np.int32) handler3_gains = np.array([1.7], dtype=np.float32) handler3_split = [_gen_categorical_split_info(0, 3, -0.75, 1.93)] # Grow tree ensemble layer by layer. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=0.1, partition_ids=[ handler1_partitions, handler2_partitions, handler3_partitions ], gains=[handler1_gains, handler2_gains, handler3_gains], splits=[handler1_split, handler2_split, handler3_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect the split for partition 1 to be chosen from handler 1 and # the split for partition 2 to be chosen from handler 2. # The grown tree should not be finalized as max tree depth is 3 and # it's only grown 2 layers. # The partition 1 split weights get added to original leaf weight 7.143. # The partition 2 split weights get added to original leaf weight -4.375. new_stamp, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) stats = session.run( training_ops.tree_ensemble_stats(tree_ensemble_handle, stamp_token=1)) tree_ensemble_config.ParseFromString(serialized) expected_result = """ trees { nodes { categorical_id_binary_split { feature_id: 4 left_id: 1 right_id: 2 } node_metadata { gain: 7.62 } } nodes { dense_float_binary_split { threshold: 0.21 left_id: 3 right_id: 4 } node_metadata { gain: 1.4 } } nodes { categorical_id_binary_split { feature_column: 1 feature_id: 7 left_id: 5 right_id: 6 } node_metadata { gain: 2.7 } } nodes { leaf { sparse_vector { index: 0 value: 1.143 } } } nodes { leaf { sparse_vector { index: 0 value: 8.793 } } } nodes { leaf { sparse_vector { index: 0 value: -5.875 } } } nodes { leaf { sparse_vector { index: 0 value: -2.075 } } } } tree_weights: 0.1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 2 } growing_metadata { num_trees_attempted: 1 num_layers_attempted: 2 } """ self.assertEqual(new_stamp, 1) self.assertEqual(stats.num_trees, 0) self.assertEqual(stats.num_layers, 2) self.assertEqual(stats.active_tree, 1) self.assertEqual(stats.active_layer, 2) self.assertEqual(stats.attempted_trees, 1) self.assertEqual(stats.attempted_layers, 2) self.assertProtoEquals(expected_result, tree_ensemble_config) def testGrowExistingEnsembleTreeFinalizedWithDropout(self): """Test growing an existing ensemble with the last tree finalized.""" with self.test_session() as session: # Create existing ensemble with one root split and one bias tree. tree_ensemble_config = tree_config_pb2.DecisionTreeEnsembleConfig() text_format.Merge(""" trees { nodes { leaf { vector { value: -0.32 value: 0.28 } } } } trees { nodes { categorical_id_binary_split { feature_column: 3 feature_id: 7 left_id: 1 right_id: 2 } node_metadata { gain: 1.3 } } nodes { leaf { sparse_vector { index: 0 value: 2.3 } } } nodes { leaf { sparse_vector { index: 0 value: -0.9 } } } } tree_weights: 0.7 tree_weights: 1 tree_metadata { num_tree_weight_updates: 1 num_layers_grown: 1 is_finalized: true } tree_metadata { num_tree_weight_updates: 5 num_layers_grown: 1 is_finalized: true } growing_metadata { num_trees_attempted: 2 num_layers_attempted: 2 } """, tree_ensemble_config) tree_ensemble_handle = model_ops.tree_ensemble_variable( stamp_token=0, tree_ensemble_config=tree_ensemble_config.SerializeToString(), name="tree_ensemble") resources.initialize_resources(resources.shared_resources()).run() # Prepare learner config. learner_config = _gen_learner_config( num_classes=2, l1_reg=0, l2_reg=0, tree_complexity=0, max_depth=1, min_node_weight=0, pruning_mode=learner_pb2.LearnerConfig.PRE_PRUNE, growing_mode=learner_pb2.LearnerConfig.WHOLE_TREE, dropout_probability=1.0) # Prepare handler inputs. handler1_partitions = np.array([0], dtype=np.int32) handler1_gains = np.array([7.62], dtype=np.float32) handler1_split = [_gen_dense_split_info(5, 0.52, -4.375, 7.143)] handler2_partitions = np.array([0], dtype=np.int32) handler2_gains = np.array([0.63], dtype=np.float32) handler2_split = [_gen_dense_split_info(2, 0.23, -0.6, 0.24)] handler3_partitions = np.array([0], dtype=np.int32) handler3_gains = np.array([7.62], dtype=np.float32) handler3_split = [_gen_categorical_split_info(8, 7, -4.375, 7.143)] # Grow tree ensemble. grow_op = training_ops.grow_tree_ensemble( tree_ensemble_handle, stamp_token=0, next_stamp_token=1, learning_rate=1, partition_ids=[ handler1_partitions, handler2_partitions, handler3_partitions ], gains=[handler1_gains, handler2_gains, handler3_gains], splits=[handler1_split, handler2_split, handler3_split], learner_config=learner_config, dropout_seed=123, center_bias=True) session.run(grow_op) # Expect a new tree to be added with the split from handler 1. _, serialized = session.run( model_ops.tree_ensemble_serialize(tree_ensemble_handle)) tree_ensemble_config.ParseFromString(serialized) self.assertEqual(3, len(tree_ensemble_config.trees)) # Both trees got 0.5 as weights, bias tree is untouched. self.assertAllClose([0.7, 0.5, 0.5], tree_ensemble_config.tree_weights) self.assertEqual( 1, tree_ensemble_config.tree_metadata[0].num_tree_weight_updates) self.assertEqual( 6, tree_ensemble_config.tree_metadata[1].num_tree_weight_updates) self.assertEqual( 2, tree_ensemble_config.tree_metadata[2].num_tree_weight_updates) if __name__ == "__main__": googletest.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 598, 52, 5060, 6093, 593, 1190, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 6233, 14, 7204, 492, 1318, 63, 908, 199, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 2625, 492, 22876, 63, 3317, 18, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 2625, 492, 3715, 63, 815, 63, 3317, 18, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 2625, 492, 3123, 63, 888, 63, 3317, 18, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 1548, 14, 1483, 492, 1402, 63, 1483, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 1548, 14, 1483, 492, 6093, 63, 1483, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5944, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 318, 485, 2268, 63, 29144, 63, 888, 8, 1507, 63, 2888, 12, 717, 634, 17, 63, 1135, 12, 717, 634, 18, 63, 1135, 12, 717, 3123, 63, 5254, 1209, 12, 717, 1390, 63, 4631, 12, 717, 1748, 63, 932, 63, 3463, 12, 717, 29501, 316, 63, 632, 12, 717, 20772, 316, 63, 632, 12, 717, 19795, 63, 17210, 29, 403, 12, 717, 19795, 63, 10546, 63, 1866, 29, 403, 12, 717, 19795, 63, 6101, 63, 1618, 63, 27713, 29, 403, 304, 523, 408, 2499, 282, 6380, 22876, 1101, 543, 314, 6387, 2202, 1041, 523, 1101, 275, 22876, 63, 3317, 18, 14, 21424, 281, 2028, 342, 523, 1101, 14, 1507, 63, 2888, 275, 1967, 63, 2888, 523, 1101, 14, 18948, 14, 76, 17, 275, 634, 17, 63, 1135, 523, 1101, 14, 18948, 14, 76, 18, 275, 634, 18, 63, 1135, 523, 1101, 14, 18948, 14, 2350, 63, 5254, 1209, 275, 3123, 63, 5254, 1209, 523, 1101, 14, 9882, 14, 988, 63, 2350, 63, 4631, 275, 1390, 63, 4631, 523, 1101, 14, 9882, 14, 827, 63, 932, 63, 3463, 275, 1748, 63, 932, 63, 3463, 523, 1101, 14, 28461, 316, 63, 632, 275, 29501, 316, 63, 632, 523, 1101, 14, 22890, 316, 63, 632, 275, 20772, 316, 63, 632, 819, 340, 19795, 63, 17210, 365, 440, 488, 26, 272, 1101, 14, 10546, 63, 1866, 63, 10032, 281, 14, 17953, 14, 17953, 63, 17210, 275, 19795, 63, 17210, 523, 340, 19795, 63, 10546, 63, 1866, 365, 440, 488, 26, 272, 1101, 14, 10546, 63, 1866, 63, 10032, 281, 14, 17953, 14, 10546, 63, 1866, 275, 19795, 63, 10546, 63, 1866, 523, 340, 19795, 63, 6101, 63, 1618, 63, 27713, 365, 440, 488, 26, 272, 1101, 14, 10546, 63, 1866, 63, 10032, 281, 14, 17953, 14, 17953, 63, 6101, 63, 1618, 63, 27713, 275, 334, 267, 19795, 63, 6101, 63, 1618, 63, 27713, 9, 523, 372, 1101, 14, 9436, 342, 421, 199, 318, 485, 2268, 63, 7253, 63, 1294, 63, 815, 8, 3003, 12, 8765, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 304, 523, 3715, 63, 495, 275, 408, 272, 3715, 63, 932, 469, 489, 9363, 63, 1609, 63, 3008, 63, 1294, 469, 267, 3878, 63, 2301, 26, 450, 68, 267, 8765, 26, 450, 70, 489, 789, 272, 789, 272, 3602, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 272, 2451, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 624, 450, 334, 3003, 12, 8765, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 9, 523, 3715, 275, 3715, 63, 815, 63, 3317, 18, 14, 8862, 2354, 342, 523, 1318, 63, 908, 14, 11359, 8, 1294, 63, 495, 12, 3715, 9, 523, 372, 3715, 14, 9436, 342, 421, 199, 318, 485, 2268, 63, 16810, 63, 1294, 63, 815, 8, 3003, 12, 13953, 63, 344, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 304, 523, 3715, 63, 495, 275, 408, 272, 3715, 63, 932, 469, 489, 22138, 63, 344, 63, 3008, 63, 1294, 469, 267, 3878, 63, 2301, 26, 450, 68, 267, 3878, 63, 344, 26, 450, 68, 489, 789, 272, 789, 272, 3602, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 272, 2451, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 624, 450, 334, 3003, 12, 13953, 63, 344, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 9, 523, 3715, 275, 3715, 63, 815, 63, 3317, 18, 14, 8862, 2354, 342, 523, 1318, 63, 908, 14, 11359, 8, 1294, 63, 495, 12, 3715, 9, 523, 372, 3715, 14, 9436, 342, 421, 199, 318, 485, 362, 63, 8160, 63, 873, 8, 16525, 12, 946, 385, 304, 523, 372, 1625, 63, 1483, 14, 4509, 8, 31421, 690, 378, 12, 446, 16525, 1182, 946, 385, 12, 1625, 63, 1483, 14, 4250, 63, 2930, 8, 16525, 430, 421, 199, 533, 24699, 3987, 1327, 8834, 34, 2241 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 598, 52, 5060, 6093, 593, 1190, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 6233, 14, 7204, 492, 1318, 63, 908, 199, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 2625, 492, 22876, 63, 3317, 18, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 2625, 492, 3715, 63, 815, 63, 3317, 18, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 2625, 492, 3123, 63, 888, 63, 3317, 18, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 1548, 14, 1483, 492, 1402, 63, 1483, 199, 504, 3228, 14, 2828, 14, 656, 17849, 63, 14635, 14, 1548, 14, 1483, 492, 6093, 63, 1483, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5944, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 318, 485, 2268, 63, 29144, 63, 888, 8, 1507, 63, 2888, 12, 717, 634, 17, 63, 1135, 12, 717, 634, 18, 63, 1135, 12, 717, 3123, 63, 5254, 1209, 12, 717, 1390, 63, 4631, 12, 717, 1748, 63, 932, 63, 3463, 12, 717, 29501, 316, 63, 632, 12, 717, 20772, 316, 63, 632, 12, 717, 19795, 63, 17210, 29, 403, 12, 717, 19795, 63, 10546, 63, 1866, 29, 403, 12, 717, 19795, 63, 6101, 63, 1618, 63, 27713, 29, 403, 304, 523, 408, 2499, 282, 6380, 22876, 1101, 543, 314, 6387, 2202, 1041, 523, 1101, 275, 22876, 63, 3317, 18, 14, 21424, 281, 2028, 342, 523, 1101, 14, 1507, 63, 2888, 275, 1967, 63, 2888, 523, 1101, 14, 18948, 14, 76, 17, 275, 634, 17, 63, 1135, 523, 1101, 14, 18948, 14, 76, 18, 275, 634, 18, 63, 1135, 523, 1101, 14, 18948, 14, 2350, 63, 5254, 1209, 275, 3123, 63, 5254, 1209, 523, 1101, 14, 9882, 14, 988, 63, 2350, 63, 4631, 275, 1390, 63, 4631, 523, 1101, 14, 9882, 14, 827, 63, 932, 63, 3463, 275, 1748, 63, 932, 63, 3463, 523, 1101, 14, 28461, 316, 63, 632, 275, 29501, 316, 63, 632, 523, 1101, 14, 22890, 316, 63, 632, 275, 20772, 316, 63, 632, 819, 340, 19795, 63, 17210, 365, 440, 488, 26, 272, 1101, 14, 10546, 63, 1866, 63, 10032, 281, 14, 17953, 14, 17953, 63, 17210, 275, 19795, 63, 17210, 523, 340, 19795, 63, 10546, 63, 1866, 365, 440, 488, 26, 272, 1101, 14, 10546, 63, 1866, 63, 10032, 281, 14, 17953, 14, 10546, 63, 1866, 275, 19795, 63, 10546, 63, 1866, 523, 340, 19795, 63, 6101, 63, 1618, 63, 27713, 365, 440, 488, 26, 272, 1101, 14, 10546, 63, 1866, 63, 10032, 281, 14, 17953, 14, 17953, 63, 6101, 63, 1618, 63, 27713, 275, 334, 267, 19795, 63, 6101, 63, 1618, 63, 27713, 9, 523, 372, 1101, 14, 9436, 342, 421, 199, 318, 485, 2268, 63, 7253, 63, 1294, 63, 815, 8, 3003, 12, 8765, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 304, 523, 3715, 63, 495, 275, 408, 272, 3715, 63, 932, 469, 489, 9363, 63, 1609, 63, 3008, 63, 1294, 469, 267, 3878, 63, 2301, 26, 450, 68, 267, 8765, 26, 450, 70, 489, 789, 272, 789, 272, 3602, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 272, 2451, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 624, 450, 334, 3003, 12, 8765, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 9, 523, 3715, 275, 3715, 63, 815, 63, 3317, 18, 14, 8862, 2354, 342, 523, 1318, 63, 908, 14, 11359, 8, 1294, 63, 495, 12, 3715, 9, 523, 372, 3715, 14, 9436, 342, 421, 199, 318, 485, 2268, 63, 16810, 63, 1294, 63, 815, 8, 3003, 12, 13953, 63, 344, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 304, 523, 3715, 63, 495, 275, 408, 272, 3715, 63, 932, 469, 489, 22138, 63, 344, 63, 3008, 63, 1294, 469, 267, 3878, 63, 2301, 26, 450, 68, 267, 3878, 63, 344, 26, 450, 68, 489, 789, 272, 789, 272, 3602, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 272, 2451, 63, 1739, 469, 489, 5178, 63, 4106, 469, 267, 1478, 26, 378, 267, 574, 26, 450, 70, 489, 789, 272, 789, 624, 450, 334, 3003, 12, 13953, 63, 344, 12, 3602, 63, 3463, 12, 2451, 63, 3463, 9, 523, 3715, 275, 3715, 63, 815, 63, 3317, 18, 14, 8862, 2354, 342, 523, 1318, 63, 908, 14, 11359, 8, 1294, 63, 495, 12, 3715, 9, 523, 372, 3715, 14, 9436, 342, 421, 199, 318, 485, 362, 63, 8160, 63, 873, 8, 16525, 12, 946, 385, 304, 523, 372, 1625, 63, 1483, 14, 4509, 8, 31421, 690, 378, 12, 446, 16525, 1182, 946, 385, 12, 1625, 63, 1483, 14, 4250, 63, 2930, 8, 16525, 430, 421, 199, 533, 24699, 3987, 1327, 8834, 34, 2241, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # This small script updates the libvirt CPU map to add a gate64 cpu model # that can be used to enable a common 64bit capable feature set across # devstack nodes so that features like nova live migration work. import sys import xml.etree.ElementTree as ET from xml.dom import minidom def update_cpu_map(tree): root = tree.getroot() cpus = root#.find("cpus") x86 = None for arch in cpus.findall("arch"): if arch.get("name") == "x86": x86 = arch break if x86 is not None: # Create a gate64 cpu model that is core2duo less monitor, pse36, # vme, and ssse3. gate64 = ET.SubElement(x86, "model") gate64.set("name", "gate64") ET.SubElement(gate64, "vendor").set("name", "Intel") ET.SubElement(gate64, "feature").set("name", "fpu") ET.SubElement(gate64, "feature").set("name", "de") ET.SubElement(gate64, "feature").set("name", "pse") ET.SubElement(gate64, "feature").set("name", "tsc") ET.SubElement(gate64, "feature").set("name", "msr") ET.SubElement(gate64, "feature").set("name", "pae") ET.SubElement(gate64, "feature").set("name", "mce") ET.SubElement(gate64, "feature").set("name", "cx8") ET.SubElement(gate64, "feature").set("name", "apic") ET.SubElement(gate64, "feature").set("name", "sep") ET.SubElement(gate64, "feature").set("name", "pge") ET.SubElement(gate64, "feature").set("name", "cmov") ET.SubElement(gate64, "feature").set("name", "pat") ET.SubElement(gate64, "feature").set("name", "mmx") ET.SubElement(gate64, "feature").set("name", "fxsr") ET.SubElement(gate64, "feature").set("name", "sse") ET.SubElement(gate64, "feature").set("name", "sse2") ET.SubElement(gate64, "feature").set("name", "mtrr") ET.SubElement(gate64, "feature").set("name", "mca") ET.SubElement(gate64, "feature").set("name", "clflush") ET.SubElement(gate64, "feature").set("name", "pni") ET.SubElement(gate64, "feature").set("name", "nx") ET.SubElement(gate64, "feature").set("name", "syscall") ET.SubElement(gate64, "feature").set("name", "lm") def format_xml(root): # Adapted from http://pymotw.com/2/xml/etree/ElementTree/create.html # thank you dhellmann rough_string = ET.tostring(root, encoding="UTF-8") dom_parsed = minidom.parseString(rough_string) return dom_parsed.toprettyxml(" ", encoding="UTF-8") def main(): if len(sys.argv) != 2: raise Exception("Must pass path to cpu_map.xml to update") cpu_map = sys.argv[1] tree = ET.parse(cpu_map) for model in tree.getroot().iter("model"): if model.get("name") == "gate64": # gate64 model is already present return update_cpu_map(tree) pretty_xml = format_xml(tree.getroot()) with open(cpu_map, 'w') as f: f.write(pretty_xml) if __name__ == "__main__": main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 961, 7425, 2884, 7029, 314, 13108, 11952, 2341, 370, 1050, 282, 17036, 772, 5033, 1402, 199, 3, 626, 883, 506, 1202, 370, 4756, 282, 2863, 5049, 2075, 4021, 461, 3878, 663, 9371, 199, 3, 4866, 2340, 3380, 880, 626, 4534, 2839, 5913, 12166, 8367, 1736, 14, 199, 199, 646, 984, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 504, 2748, 14, 4556, 492, 19165, 421, 199, 318, 1678, 63, 3541, 63, 1130, 8, 2350, 304, 272, 1738, 275, 3123, 14, 24544, 342, 272, 24174, 275, 1738, 31827, 1623, 480, 8896, 531, 272, 671, 1184, 275, 488, 272, 367, 3819, 315, 24174, 14, 6452, 480, 1047, 2349, 267, 340, 3819, 14, 362, 480, 354, 531, 508, 298, 88, 1184, 582, 288, 671, 1184, 275, 3819, 288, 2059, 272, 340, 671, 1184, 365, 440, 488, 26, 267, 327, 2790, 282, 17036, 772, 5033, 1402, 626, 365, 6170, 18, 2033, 79, 6656, 8372, 12, 299, 261, 1344, 12, 267, 327, 373, 278, 12, 436, 10110, 261, 19, 14, 267, 17036, 772, 275, 12265, 14, 10571, 8, 88, 1184, 12, 298, 1238, 531, 267, 17036, 772, 14, 409, 480, 354, 401, 298, 3237, 772, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 9884, 3471, 409, 480, 354, 401, 298, 27528, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 70, 3165, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 271, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 80, 261, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 84, 551, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 706, 82, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 387, 69, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 77, 301, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 11859, 24, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 20789, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 4127, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 80, 303, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 67, 14469, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 10853, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 596, 88, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 12220, 5474, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 28780, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 28780, 18, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 77, 454, 82, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 77, 696, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 9694, 76, 2084, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 4812, 73, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 7343, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 19444, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 14344, 531, 421, 199, 318, 1475, 63, 1652, 8, 1231, 304, 272, 327, 4431, 18309, 687, 1455, 921, 647, 30034, 87, 14, 957, 15, 18, 15, 1652, 15, 9464, 15, 15325, 15, 981, 14, 1360, 272, 327, 2419, 75, 1265, 31387, 1697, 20059, 272, 28568, 63, 875, 275, 12265, 14, 14028, 8, 1231, 12, 2644, 628, 6610, 13, 24, 531, 272, 8266, 63, 6751, 275, 19165, 14, 14934, 8, 3202, 63, 875, 9, 272, 372, 8266, 63, 6751, 14, 2119, 21958, 1652, 480, 221, 3872, 2644, 628, 6610, 13, 24, 531, 421, 199, 318, 2446, 837, 272, 340, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 267, 746, 2186, 480, 13757, 986, 931, 370, 5033, 63, 1130, 14, 1652, 370, 1678, 531, 272, 5033, 63, 1130, 275, 984, 14, 3020, 59, 17, 61, 272, 3123, 275, 12265, 14, 1122, 8, 3541, 63, 1130, 9, 272, 367, 1402, 315, 3123, 14, 24544, 1252, 1661, 480, 1238, 2349, 267, 340, 1402, 14, 362, 480, 354, 531, 508, 298, 3237, 772, 582, 288, 327, 17036, 772, 1402, 365, 2575, 3451, 288, 372, 272, 1678, 63, 3541, 63, 1130, 8, 2350, 9, 272, 7268, 63, 1652, 275, 1475, 63, 1652, 8, 2350, 14, 24544, 1012, 272, 543, 1551, 8, 3541, 63, 1130, 12, 283, 87, 358, 465, 289, 26, 267, 289, 14, 952, 8, 9118, 63, 1652 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 961, 7425, 2884, 7029, 314, 13108, 11952, 2341, 370, 1050, 282, 17036, 772, 5033, 1402, 199, 3, 626, 883, 506, 1202, 370, 4756, 282, 2863, 5049, 2075, 4021, 461, 3878, 663, 9371, 199, 3, 4866, 2340, 3380, 880, 626, 4534, 2839, 5913, 12166, 8367, 1736, 14, 199, 199, 646, 984, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 504, 2748, 14, 4556, 492, 19165, 421, 199, 318, 1678, 63, 3541, 63, 1130, 8, 2350, 304, 272, 1738, 275, 3123, 14, 24544, 342, 272, 24174, 275, 1738, 31827, 1623, 480, 8896, 531, 272, 671, 1184, 275, 488, 272, 367, 3819, 315, 24174, 14, 6452, 480, 1047, 2349, 267, 340, 3819, 14, 362, 480, 354, 531, 508, 298, 88, 1184, 582, 288, 671, 1184, 275, 3819, 288, 2059, 272, 340, 671, 1184, 365, 440, 488, 26, 267, 327, 2790, 282, 17036, 772, 5033, 1402, 626, 365, 6170, 18, 2033, 79, 6656, 8372, 12, 299, 261, 1344, 12, 267, 327, 373, 278, 12, 436, 10110, 261, 19, 14, 267, 17036, 772, 275, 12265, 14, 10571, 8, 88, 1184, 12, 298, 1238, 531, 267, 17036, 772, 14, 409, 480, 354, 401, 298, 3237, 772, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 9884, 3471, 409, 480, 354, 401, 298, 27528, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 70, 3165, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 271, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 80, 261, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 84, 551, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 706, 82, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 387, 69, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 77, 301, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 11859, 24, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 20789, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 4127, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 80, 303, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 67, 14469, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 10853, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 596, 88, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 12220, 5474, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 28780, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 28780, 18, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 77, 454, 82, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 77, 696, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 9694, 76, 2084, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 4812, 73, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 7343, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 19444, 531, 267, 12265, 14, 10571, 8, 3237, 772, 12, 298, 4445, 3471, 409, 480, 354, 401, 298, 14344, 531, 421, 199, 318, 1475, 63, 1652, 8, 1231, 304, 272, 327, 4431, 18309, 687, 1455, 921, 647, 30034, 87, 14, 957, 15, 18, 15, 1652, 15, 9464, 15, 15325, 15, 981, 14, 1360, 272, 327, 2419, 75, 1265, 31387, 1697, 20059, 272, 28568, 63, 875, 275, 12265, 14, 14028, 8, 1231, 12, 2644, 628, 6610, 13, 24, 531, 272, 8266, 63, 6751, 275, 19165, 14, 14934, 8, 3202, 63, 875, 9, 272, 372, 8266, 63, 6751, 14, 2119, 21958, 1652, 480, 221, 3872, 2644, 628, 6610, 13, 24, 531, 421, 199, 318, 2446, 837, 272, 340, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 267, 746, 2186, 480, 13757, 986, 931, 370, 5033, 63, 1130, 14, 1652, 370, 1678, 531, 272, 5033, 63, 1130, 275, 984, 14, 3020, 59, 17, 61, 272, 3123, 275, 12265, 14, 1122, 8, 3541, 63, 1130, 9, 272, 367, 1402, 315, 3123, 14, 24544, 1252, 1661, 480, 1238, 2349, 267, 340, 1402, 14, 362, 480, 354, 531, 508, 298, 3237, 772, 582, 288, 327, 17036, 772, 1402, 365, 2575, 3451, 288, 372, 272, 1678, 63, 3541, 63, 1130, 8, 2350, 9, 272, 7268, 63, 1652, 275, 1475, 63, 1652, 8, 2350, 14, 24544, 1012, 272, 543, 1551, 8, 3541, 63, 1130, 12, 283, 87, 358, 465, 289, 26, 267, 289, 14, 952, 8, 9118, 63,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 1, 1, 1, 1 ]
rubenvereecken/pokemongo-api
POGOProtos/Data/Gym/GymMembership_pb2.py
10
3305
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: POGOProtos/Data/Gym/GymMembership.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() from POGOProtos.Data import PokemonData_pb2 as POGOProtos_dot_Data_dot_PokemonData__pb2 from POGOProtos.Data.Player import PlayerPublicProfile_pb2 as POGOProtos_dot_Data_dot_Player_dot_PlayerPublicProfile__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='POGOProtos/Data/Gym/GymMembership.proto', package='POGOProtos.Data.Gym', syntax='proto3', serialized_pb=_b('\n\'POGOProtos/Data/Gym/GymMembership.proto\x12\x13POGOProtos.Data.Gym\x1a!POGOProtos/Data/PokemonData.proto\x1a\x30POGOProtos/Data/Player/PlayerPublicProfile.proto\"\x90\x01\n\rGymMembership\x12\x32\n\x0cpokemon_data\x18\x01 \x01(\x0b\x32\x1c.POGOProtos.Data.PokemonData\x12K\n\x16trainer_public_profile\x18\x02 \x01(\x0b\x32+.POGOProtos.Data.Player.PlayerPublicProfileb\x06proto3') , dependencies=[POGOProtos_dot_Data_dot_PokemonData__pb2.DESCRIPTOR,POGOProtos_dot_Data_dot_Player_dot_PlayerPublicProfile__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _GYMMEMBERSHIP = _descriptor.Descriptor( name='GymMembership', full_name='POGOProtos.Data.Gym.GymMembership', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='pokemon_data', full_name='POGOProtos.Data.Gym.GymMembership.pokemon_data', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='trainer_public_profile', full_name='POGOProtos.Data.Gym.GymMembership.trainer_public_profile', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=150, serialized_end=294, ) _GYMMEMBERSHIP.fields_by_name['pokemon_data'].message_type = POGOProtos_dot_Data_dot_PokemonData__pb2._POKEMONDATA _GYMMEMBERSHIP.fields_by_name['trainer_public_profile'].message_type = POGOProtos_dot_Data_dot_Player_dot_PlayerPublicProfile__pb2._PLAYERPUBLICPROFILE DESCRIPTOR.message_types_by_name['GymMembership'] = _GYMMEMBERSHIP GymMembership = _reflection.GeneratedProtocolMessageType('GymMembership', (_message.Message,), dict( DESCRIPTOR = _GYMMEMBERSHIP, __module__ = 'POGOProtos.Data.Gym.GymMembership_pb2' # @@protoc_insertion_point(class_scope:POGOProtos.Data.Gym.GymMembership) )) _sym_db.RegisterMessage(GymMembership) # @@protoc_insertion_point(module_scope)
mit
[ 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 3625, 23114, 15, 1451, 15, 39, 12828, 15, 39, 12828, 19480, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 504, 3625, 23114, 14, 1451, 492, 4376, 17180, 1451, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 1575, 17180, 1451, 363, 3317, 18, 199, 504, 3625, 23114, 14, 1451, 14, 10921, 492, 25610, 9885, 5736, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 26676, 15, 1451, 15, 39, 12828, 15, 39, 12828, 19480, 14, 2625, 297, 523, 2559, 534, 26676, 14, 1451, 14, 39, 12828, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 3985, 26676, 15, 1451, 15, 39, 12828, 15, 39, 12828, 19480, 14, 2625, 60, 88, 713, 60, 88, 969, 26676, 14, 1451, 14, 39, 12828, 60, 88, 17, 65, 1, 26676, 15, 1451, 15, 1575, 17180, 1451, 14, 2625, 60, 88, 17, 65, 60, 88, 1216, 26676, 15, 1451, 15, 10921, 15, 10921, 9885, 5736, 14, 2625, 13356, 88, 2710, 60, 88, 614, 60, 78, 60, 82, 39, 12828, 19480, 60, 88, 713, 60, 88, 708, 60, 78, 60, 88, 16, 67, 28331, 63, 576, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 67, 14, 26676, 14, 1451, 14, 1575, 17180, 1451, 60, 88, 713, 43, 60, 78, 60, 88, 975, 2834, 281, 63, 3455, 63, 2913, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 26240, 26676, 14, 1451, 14, 10921, 14, 10921, 9885, 5736, 66, 60, 88, 1690, 2625, 19, 358, 523, 2360, 523, 5124, 1524, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 1575, 17180, 1451, 363, 3317, 18, 14, 7580, 12, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 14, 7580, 30453, 199, 63, 3840, 63, 697, 14, 7099, 23859, 8, 7580, 9, 6905, 199, 63, 15489, 3218, 2769, 12003, 3234, 1772, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 39, 12828, 19480, 297, 523, 2615, 63, 354, 534, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 28331, 63, 576, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 14, 28331, 63, 576, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 2834, 281, 63, 3455, 63, 2913, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 14, 2834, 281, 63, 3455, 63, 2913, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 523, 2156, 523, 5478, 1524, 523, 2156, 523, 6032, 63, 1313, 6034, 523, 4952, 63, 1313, 1524, 523, 2156, 523, 1511, 29, 403, 12, 523, 365, 63, 18363, 29, 797, 12, 523, 6302, 534, 2625, 19, 297, 523, 3329, 63, 8404, 6034, 523, 20753, 1524, 523, 2156, 523, 6380, 63, 928, 29, 8251, 12, 523, 6380, 63, 500, 29, 10693, 12, 199, 9, 199, 199, 63, 15489, 3218, 2769, 12003, 3234, 1772, 14, 955, 63, 991, 63, 354, 459, 28331, 63, 576, 2278, 1188, 63, 466, 275, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 1575, 17180, 1451, 363, 3317, 18, 423, 1512, 2430, 11710, 3998, 199, 63, 15489, 3218, 2769, 12003, 3234, 1772, 14, 955, 63, 991, 63, 354, 459, 2834, 281, 63, 3455, 63, 2913, 2278, 1188, 63, 466, 275, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 423, 11625, 6758, 2533, 2507, 16632, 199, 7580, 14, 1188, 63, 1313, 63, 991, 63, 354, 459, 39, 12828, 19480, 418, 275, 485, 15489, 3218, 2769, 12003, 3234, 1772, 199, 199, 39, 12828, 19480, 275, 485, 14906, 14, 18818, 360, 39, 12828, 19480, 297, 6110, 1188, 14, 2209, 4706, 1211, 8, 523, 21034, 275, 485, 15489, 3218, 2769, 12003, 3234, 1772, 12, 523, 636, 578, 363, 275, 283, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 63, 3317, 18, 7, 523, 327, 13365, 16311, 63, 14739, 63, 1403, 8, 533, 63, 2645, 26, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 9, 523, 5082, 199, 63, 3840, 63, 697, 14, 20917, 8, 39, 12828, 19480 ]
[ 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 3625, 23114, 15, 1451, 15, 39, 12828, 15, 39, 12828, 19480, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 504, 3625, 23114, 14, 1451, 492, 4376, 17180, 1451, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 1575, 17180, 1451, 363, 3317, 18, 199, 504, 3625, 23114, 14, 1451, 14, 10921, 492, 25610, 9885, 5736, 63, 3317, 18, 465, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 26676, 15, 1451, 15, 39, 12828, 15, 39, 12828, 19480, 14, 2625, 297, 523, 2559, 534, 26676, 14, 1451, 14, 39, 12828, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 3985, 26676, 15, 1451, 15, 39, 12828, 15, 39, 12828, 19480, 14, 2625, 60, 88, 713, 60, 88, 969, 26676, 14, 1451, 14, 39, 12828, 60, 88, 17, 65, 1, 26676, 15, 1451, 15, 1575, 17180, 1451, 14, 2625, 60, 88, 17, 65, 60, 88, 1216, 26676, 15, 1451, 15, 10921, 15, 10921, 9885, 5736, 14, 2625, 13356, 88, 2710, 60, 88, 614, 60, 78, 60, 82, 39, 12828, 19480, 60, 88, 713, 60, 88, 708, 60, 78, 60, 88, 16, 67, 28331, 63, 576, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 67, 14, 26676, 14, 1451, 14, 1575, 17180, 1451, 60, 88, 713, 43, 60, 78, 60, 88, 975, 2834, 281, 63, 3455, 63, 2913, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 26240, 26676, 14, 1451, 14, 10921, 14, 10921, 9885, 5736, 66, 60, 88, 1690, 2625, 19, 358, 523, 2360, 523, 5124, 1524, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 1575, 17180, 1451, 363, 3317, 18, 14, 7580, 12, 26676, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 14, 7580, 30453, 199, 63, 3840, 63, 697, 14, 7099, 23859, 8, 7580, 9, 6905, 199, 63, 15489, 3218, 2769, 12003, 3234, 1772, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 39, 12828, 19480, 297, 523, 2615, 63, 354, 534, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 28331, 63, 576, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 14, 28331, 63, 576, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 2834, 281, 63, 3455, 63, 2913, 297, 2615, 63, 354, 534, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 14, 2834, 281, 63, 3455, 63, 2913, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 845, 12, 7246, 63, 466, 29, 709, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 403, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 1511, 29, 403, 395, 523, 2156, 523, 5478, 1524, 523, 2156, 523, 6032, 63, 1313, 6034, 523, 4952, 63, 1313, 1524, 523, 2156, 523, 1511, 29, 403, 12, 523, 365, 63, 18363, 29, 797, 12, 523, 6302, 534, 2625, 19, 297, 523, 3329, 63, 8404, 6034, 523, 20753, 1524, 523, 2156, 523, 6380, 63, 928, 29, 8251, 12, 523, 6380, 63, 500, 29, 10693, 12, 199, 9, 199, 199, 63, 15489, 3218, 2769, 12003, 3234, 1772, 14, 955, 63, 991, 63, 354, 459, 28331, 63, 576, 2278, 1188, 63, 466, 275, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 1575, 17180, 1451, 363, 3317, 18, 423, 1512, 2430, 11710, 3998, 199, 63, 15489, 3218, 2769, 12003, 3234, 1772, 14, 955, 63, 991, 63, 354, 459, 2834, 281, 63, 3455, 63, 2913, 2278, 1188, 63, 466, 275, 3625, 23114, 63, 3287, 63, 1451, 63, 3287, 63, 10921, 63, 3287, 63, 10921, 9885, 5736, 363, 3317, 18, 423, 11625, 6758, 2533, 2507, 16632, 199, 7580, 14, 1188, 63, 1313, 63, 991, 63, 354, 459, 39, 12828, 19480, 418, 275, 485, 15489, 3218, 2769, 12003, 3234, 1772, 199, 199, 39, 12828, 19480, 275, 485, 14906, 14, 18818, 360, 39, 12828, 19480, 297, 6110, 1188, 14, 2209, 4706, 1211, 8, 523, 21034, 275, 485, 15489, 3218, 2769, 12003, 3234, 1772, 12, 523, 636, 578, 363, 275, 283, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 63, 3317, 18, 7, 523, 327, 13365, 16311, 63, 14739, 63, 1403, 8, 533, 63, 2645, 26, 26676, 14, 1451, 14, 39, 12828, 14, 39, 12828, 19480, 9, 523, 5082, 199, 63, 3840, 63, 697, 14, 20917, 8, 39, 12828, 19480, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
oew1v07/scikit-image
skimage/morphology/tests/test_binary.py
33
5898
import numpy as np from numpy import testing from skimage import data, color from skimage.util import img_as_bool from skimage.morphology import binary, grey, selem from scipy import ndimage as ndi img = color.rgb2gray(data.astronaut()) bw_img = img > 100 def test_non_square_image(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img[:100, :200], strel) grey_res = img_as_bool(grey.erosion(bw_img[:100, :200], strel)) testing.assert_array_equal(binary_res, grey_res) def test_binary_erosion(): strel = selem.square(3) binary_res = binary.binary_erosion(bw_img, strel) grey_res = img_as_bool(grey.erosion(bw_img, strel)) testing.assert_array_equal(binary_res, grey_res) def test_binary_dilation(): strel = selem.square(3) binary_res = binary.binary_dilation(bw_img, strel) grey_res = img_as_bool(grey.dilation(bw_img, strel)) testing.assert_array_equal(binary_res, grey_res) def test_binary_closing(): strel = selem.square(3) binary_res = binary.binary_closing(bw_img, strel) grey_res = img_as_bool(grey.closing(bw_img, strel)) testing.assert_array_equal(binary_res, grey_res) def test_binary_opening(): strel = selem.square(3) binary_res = binary.binary_opening(bw_img, strel) grey_res = img_as_bool(grey.opening(bw_img, strel)) testing.assert_array_equal(binary_res, grey_res) def test_selem_overflow(): strel = np.ones((17, 17), dtype=np.uint8) img = np.zeros((20, 20), dtype=bool) img[2:19, 2:19] = True binary_res = binary.binary_erosion(img, strel) grey_res = img_as_bool(grey.erosion(img, strel)) testing.assert_array_equal(binary_res, grey_res) def test_out_argument(): for func in (binary.binary_erosion, binary.binary_dilation): strel = np.ones((3, 3), dtype=np.uint8) img = np.ones((10, 10)) out = np.zeros_like(img) out_saved = out.copy() func(img, strel, out=out) testing.assert_(np.any(out != out_saved)) testing.assert_array_equal(out, func(img, strel)) def test_default_selem(): functions = [binary.binary_erosion, binary.binary_dilation, binary.binary_opening, binary.binary_closing] strel = selem.diamond(radius=1) image = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], np.uint8) for function in functions: im_expected = function(image, strel) im_test = function(image) yield testing.assert_array_equal, im_expected, im_test def test_3d_fallback_default_selem(): # 3x3x3 cube inside a 7x7x7 image: image = np.zeros((7, 7, 7), np.bool) image[2:-2, 2:-2, 2:-2] = 1 opened = binary.binary_opening(image) # expect a "hyper-cross" centered in the 5x5x5: image_expected = np.zeros((7, 7, 7), dtype=bool) image_expected[2:5, 2:5, 2:5] = ndi.generate_binary_structure(3, 1) testing.assert_array_equal(opened, image_expected) def test_3d_fallback_cube_selem(): # 3x3x3 cube inside a 7x7x7 image: image = np.zeros((7, 7, 7), np.bool) image[2:-2, 2:-2, 2:-2] = 1 cube = np.ones((3, 3, 3), dtype=np.uint8) for function in [binary.binary_closing, binary.binary_opening]: new_image = function(image, cube) yield testing.assert_array_equal, new_image, image def test_2d_ndimage_equivalence(): image = np.zeros((9, 9), np.uint16) image[2:-2, 2:-2] = 2**14 image[3:-3, 3:-3] = 2**15 image[4, 4] = 2**16-1 bin_opened = binary.binary_opening(image) bin_closed = binary.binary_closing(image) selem = ndi.generate_binary_structure(2, 1) ndimage_opened = ndi.binary_opening(image, structure=selem) ndimage_closed = ndi.binary_closing(image, structure=selem) testing.assert_array_equal(bin_opened, ndimage_opened) testing.assert_array_equal(bin_closed, ndimage_closed) def test_binary_output_2d(): image = np.zeros((9, 9), np.uint16) image[2:-2, 2:-2] = 2**14 image[3:-3, 3:-3] = 2**15 image[4, 4] = 2**16-1 bin_opened = binary.binary_opening(image) bin_closed = binary.binary_closing(image) int_opened = np.empty_like(image, dtype=np.uint8) int_closed = np.empty_like(image, dtype=np.uint8) binary.binary_opening(image, out=int_opened) binary.binary_closing(image, out=int_closed) testing.assert_equal(bin_opened.dtype, np.bool) testing.assert_equal(bin_closed.dtype, np.bool) testing.assert_equal(int_opened.dtype, np.uint8) testing.assert_equal(int_closed.dtype, np.uint8) def test_binary_output_3d(): image = np.zeros((9, 9, 9), np.uint16) image[2:-2, 2:-2, 2:-2] = 2**14 image[3:-3, 3:-3, 3:-3] = 2**15 image[4, 4, 4] = 2**16-1 bin_opened = binary.binary_opening(image) bin_closed = binary.binary_closing(image) int_opened = np.empty_like(image, dtype=np.uint8) int_closed = np.empty_like(image, dtype=np.uint8) binary.binary_opening(image, out=int_opened) binary.binary_closing(image, out=int_closed) testing.assert_equal(bin_opened.dtype, np.bool) testing.assert_equal(bin_closed.dtype, np.bool) testing.assert_equal(int_opened.dtype, np.uint8) testing.assert_equal(int_closed.dtype, np.uint8) if __name__ == '__main__': testing.run_module_suite()
bsd-3-clause
[ 646, 2680, 465, 980, 199, 504, 2680, 492, 5343, 199, 199, 504, 2386, 1569, 492, 666, 12, 3164, 199, 504, 2386, 1569, 14, 1974, 492, 6050, 63, 305, 63, 2245, 199, 504, 2386, 1569, 14, 12416, 21936, 4956, 492, 3366, 12, 30357, 12, 542, 3701, 199, 504, 7026, 492, 302, 23335, 465, 302, 328, 421, 199, 4060, 275, 3164, 14, 10090, 18, 12150, 8, 576, 14, 65, 495, 265, 6898, 1012, 199, 12415, 63, 4060, 275, 6050, 690, 2948, 421, 199, 318, 511, 63, 2865, 63, 9646, 63, 1569, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 3478, 438, 8, 12415, 63, 4060, 1491, 1960, 12, 520, 1840, 467, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 3478, 438, 8, 12415, 63, 4060, 1491, 1960, 12, 520, 1840, 467, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 3478, 438, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 3478, 438, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 3478, 438, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 328, 2212, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 328, 2212, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 328, 2212, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 11707, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 11707, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 11707, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 21849, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 21849, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 21849, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 261, 3701, 63, 14108, 837, 272, 410, 3369, 275, 980, 14, 4548, 1332, 1196, 12, 5557, 395, 2152, 29, 1590, 14, 1635, 24, 9, 272, 6050, 275, 980, 14, 4250, 1332, 1165, 12, 3388, 395, 2152, 29, 2245, 9, 272, 6050, 59, 18, 26, 1167, 12, 499, 26, 1167, 61, 275, 715, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 3478, 438, 8, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 3478, 438, 8, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 548, 63, 2094, 837, 272, 367, 2562, 315, 334, 3008, 14, 3008, 63, 3478, 438, 12, 3366, 14, 3008, 63, 328, 2212, 304, 267, 410, 3369, 275, 980, 14, 4548, 1332, 19, 12, 650, 395, 2152, 29, 1590, 14, 1635, 24, 9, 267, 6050, 275, 980, 14, 4548, 1332, 709, 12, 1616, 430, 267, 734, 275, 980, 14, 4250, 63, 2930, 8, 4060, 9, 267, 734, 63, 8420, 275, 734, 14, 1574, 342, 267, 2562, 8, 4060, 12, 410, 3369, 12, 734, 29, 548, 9, 267, 5343, 14, 479, 2531, 1590, 14, 1629, 8, 548, 1137, 734, 63, 8420, 430, 267, 5343, 14, 479, 63, 1144, 63, 1452, 8, 548, 12, 2562, 8, 4060, 12, 410, 3369, 430, 199, 199, 318, 511, 63, 885, 63, 261, 3701, 837, 272, 3423, 275, 359, 3008, 14, 3008, 63, 3478, 438, 12, 3366, 14, 3008, 63, 328, 2212, 12, 326, 3366, 14, 3008, 63, 21849, 12, 3366, 14, 3008, 63, 11707, 61, 272, 410, 3369, 275, 542, 3701, 14, 328, 24940, 8, 8017, 29, 17, 9, 272, 1834, 275, 980, 14, 1144, 4038, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16 ]
[ 2680, 465, 980, 199, 504, 2680, 492, 5343, 199, 199, 504, 2386, 1569, 492, 666, 12, 3164, 199, 504, 2386, 1569, 14, 1974, 492, 6050, 63, 305, 63, 2245, 199, 504, 2386, 1569, 14, 12416, 21936, 4956, 492, 3366, 12, 30357, 12, 542, 3701, 199, 504, 7026, 492, 302, 23335, 465, 302, 328, 421, 199, 4060, 275, 3164, 14, 10090, 18, 12150, 8, 576, 14, 65, 495, 265, 6898, 1012, 199, 12415, 63, 4060, 275, 6050, 690, 2948, 421, 199, 318, 511, 63, 2865, 63, 9646, 63, 1569, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 3478, 438, 8, 12415, 63, 4060, 1491, 1960, 12, 520, 1840, 467, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 3478, 438, 8, 12415, 63, 4060, 1491, 1960, 12, 520, 1840, 467, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 3478, 438, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 3478, 438, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 3478, 438, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 328, 2212, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 328, 2212, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 328, 2212, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 11707, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 11707, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 11707, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 3008, 63, 21849, 837, 272, 410, 3369, 275, 542, 3701, 14, 9646, 8, 19, 9, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 21849, 8, 12415, 63, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 21849, 8, 12415, 63, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 261, 3701, 63, 14108, 837, 272, 410, 3369, 275, 980, 14, 4548, 1332, 1196, 12, 5557, 395, 2152, 29, 1590, 14, 1635, 24, 9, 272, 6050, 275, 980, 14, 4250, 1332, 1165, 12, 3388, 395, 2152, 29, 2245, 9, 272, 6050, 59, 18, 26, 1167, 12, 499, 26, 1167, 61, 275, 715, 272, 3366, 63, 470, 275, 3366, 14, 3008, 63, 3478, 438, 8, 4060, 12, 410, 3369, 9, 272, 30357, 63, 470, 275, 6050, 63, 305, 63, 2245, 8, 16708, 14, 3478, 438, 8, 4060, 12, 410, 3369, 430, 272, 5343, 14, 479, 63, 1144, 63, 1452, 8, 3008, 63, 470, 12, 30357, 63, 470, 9, 421, 199, 318, 511, 63, 548, 63, 2094, 837, 272, 367, 2562, 315, 334, 3008, 14, 3008, 63, 3478, 438, 12, 3366, 14, 3008, 63, 328, 2212, 304, 267, 410, 3369, 275, 980, 14, 4548, 1332, 19, 12, 650, 395, 2152, 29, 1590, 14, 1635, 24, 9, 267, 6050, 275, 980, 14, 4548, 1332, 709, 12, 1616, 430, 267, 734, 275, 980, 14, 4250, 63, 2930, 8, 4060, 9, 267, 734, 63, 8420, 275, 734, 14, 1574, 342, 267, 2562, 8, 4060, 12, 410, 3369, 12, 734, 29, 548, 9, 267, 5343, 14, 479, 2531, 1590, 14, 1629, 8, 548, 1137, 734, 63, 8420, 430, 267, 5343, 14, 479, 63, 1144, 63, 1452, 8, 548, 12, 2562, 8, 4060, 12, 410, 3369, 430, 199, 199, 318, 511, 63, 885, 63, 261, 3701, 837, 272, 3423, 275, 359, 3008, 14, 3008, 63, 3478, 438, 12, 3366, 14, 3008, 63, 328, 2212, 12, 326, 3366, 14, 3008, 63, 21849, 12, 3366, 14, 3008, 63, 11707, 61, 272, 410, 3369, 275, 542, 3701, 14, 328, 24940, 8, 8017, 29, 17, 9, 272, 1834, 275, 980, 14, 1144, 4038, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 12, 378, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 413, 12, 378, 12, 378, 467, 1993, 359, 16, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Rezzie/Batcher
generators/g_randomchoice.py
1
2268
#!/usr/bin/env python # Copyright (c) 2011, The University of York # All rights reserved. # Author(s): # James Arnold <jarnie@gmail.com> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the The University of York nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF YORK BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from generator import Generator import random class random_choice(Generator): def __init__(self, choices, seed=None): assert len(choices) > 0 self.__choices = choices if seed is not None: random.seed(seed) def Generate(self): """Return one of the choices at random.""" while True: yield random.choice(self.__choices) if __name__ == "__main__": from generator import PrintExamples options = {'choices': ["James", "Ralph", "Rob", "Mike", "Harry"], 'seed': 2398639} gen = random_choice(**options) PrintExamples(gen)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7760, 12, 710, 15904, 402, 1488, 4708, 199, 3, 2900, 4481, 4644, 14, 199, 3, 6529, 8, 83, 304, 199, 3, 257, 1603, 14015, 1952, 78, 1753, 665, 74, 1060, 1873, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 314, 710, 15904, 402, 1488, 4708, 6590, 314, 199, 3, 755, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 755, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 6778, 41, 17223, 1922, 1634, 1488, 726, 43, 6262, 7024, 2381, 1821, 199, 3, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 4306, 492, 15042, 199, 199, 646, 2196, 421, 199, 533, 2196, 63, 5095, 8, 7599, 304, 339, 347, 636, 826, 721, 277, 12, 3415, 12, 6347, 29, 403, 304, 398, 702, 822, 8, 4577, 9, 690, 378, 398, 291, 855, 4577, 275, 3415, 398, 340, 6347, 365, 440, 488, 26, 288, 2196, 14, 5176, 8, 5176, 9, 2378, 347, 7958, 8, 277, 304, 267, 408, 1767, 1373, 402, 314, 3415, 737, 2196, 1041, 267, 1830, 715, 26, 288, 1995, 2196, 14, 5095, 8, 277, 855, 4577, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 687, 4306, 492, 9101, 22787, 339, 1511, 275, 791, 4577, 356, 2097, 42, 14015, 401, 298, 50, 10305, 401, 298, 50, 2873, 401, 298, 45, 7455, 401, 298, 18248, 651, 2255, 2049, 283, 5176, 356, 499, 29451, 1355, 93, 272, 3805, 275, 2196, 63, 5095, 3682, 1419, 9, 272, 9101, 22787, 8, 2268, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7760, 12, 710, 15904, 402, 1488, 4708, 199, 3, 2900, 4481, 4644, 14, 199, 3, 6529, 8, 83, 304, 199, 3, 257, 1603, 14015, 1952, 78, 1753, 665, 74, 1060, 1873, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 314, 710, 15904, 402, 1488, 4708, 6590, 314, 199, 3, 755, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 755, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 6778, 41, 17223, 1922, 1634, 1488, 726, 43, 6262, 7024, 2381, 1821, 199, 3, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 4306, 492, 15042, 199, 199, 646, 2196, 421, 199, 533, 2196, 63, 5095, 8, 7599, 304, 339, 347, 636, 826, 721, 277, 12, 3415, 12, 6347, 29, 403, 304, 398, 702, 822, 8, 4577, 9, 690, 378, 398, 291, 855, 4577, 275, 3415, 398, 340, 6347, 365, 440, 488, 26, 288, 2196, 14, 5176, 8, 5176, 9, 2378, 347, 7958, 8, 277, 304, 267, 408, 1767, 1373, 402, 314, 3415, 737, 2196, 1041, 267, 1830, 715, 26, 288, 1995, 2196, 14, 5095, 8, 277, 855, 4577, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 687, 4306, 492, 9101, 22787, 339, 1511, 275, 791, 4577, 356, 2097, 42, 14015, 401, 298, 50, 10305, 401, 298, 50, 2873, 401, 298, 45, 7455, 401, 298, 18248, 651, 2255, 2049, 283, 5176, 356, 499, 29451, 1355, 93, 272, 3805, 275, 2196, 63, 5095, 3682, 1419, 9, 272, 9101, 22787, 8, 2268, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Beeblio/django
django/contrib/auth/tests/test_tokens.py
117
2635
from datetime import date, timedelta import sys import unittest from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.tests.utils import skipIfCustomUser from django.test import TestCase @skipIfCustomUser class TokenGeneratorTest(TestCase): def test_make_token(self): """ Ensure that we can make a token and that it is valid """ user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw') p0 = PasswordResetTokenGenerator() tk1 = p0.make_token(user) self.assertTrue(p0.check_token(user, tk1)) def test_10265(self): """ Ensure that the token generated for a user created in the same request will work correctly. """ # See ticket #10265 user = User.objects.create_user('comebackkid', 'test3@example.com', 'testpw') p0 = PasswordResetTokenGenerator() tk1 = p0.make_token(user) reload = User.objects.get(username='comebackkid') tk2 = p0.make_token(reload) self.assertEqual(tk1, tk2) def test_timeout(self): """ Ensure we can use the token after n days, but no greater. """ # Uses a mocked version of PasswordResetTokenGenerator so we can change # the value of 'today' class Mocked(PasswordResetTokenGenerator): def __init__(self, today): self._today_val = today def _today(self): return self._today_val user = User.objects.create_user('tokentestuser', 'test2@example.com', 'testpw') p0 = PasswordResetTokenGenerator() tk1 = p0.make_token(user) p1 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS)) self.assertTrue(p1.check_token(user, tk1)) p2 = Mocked(date.today() + timedelta(settings.PASSWORD_RESET_TIMEOUT_DAYS + 1)) self.assertFalse(p2.check_token(user, tk1)) @unittest.skipIf(sys.version_info[:2] >= (3, 0), "Unnecessary test with Python 3") def test_date_length(self): """ Make sure we don't allow overly long dates, causing a potential DoS. """ user = User.objects.create_user('ima1337h4x0r', 'test4@example.com', 'p4ssw0rd') p0 = PasswordResetTokenGenerator() # This will put a 14-digit base36 timestamp into the token, which is too large. self.assertRaises(ValueError, p0._make_token_with_timestamp, user, 175455491841851871349)
bsd-3-clause
[ 504, 2197, 492, 1434, 12, 6871, 199, 646, 984, 199, 646, 2882, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4504, 492, 13635, 9637, 3264, 7599, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 396, 492, 7640, 421, 199, 32, 15118, 31482, 199, 533, 8767, 7599, 774, 8, 1746, 304, 339, 347, 511, 63, 1875, 63, 1418, 8, 277, 304, 267, 408, 267, 7523, 626, 781, 883, 1852, 282, 1526, 436, 626, 652, 365, 1686, 267, 408, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 1418, 21029, 297, 283, 396, 18, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 267, 10157, 17, 275, 299, 16, 14, 1875, 63, 1418, 8, 751, 9, 267, 291, 14, 1815, 8, 80, 16, 14, 1074, 63, 1418, 8, 751, 12, 10157, 17, 430, 339, 347, 511, 63, 709, 13730, 8, 277, 304, 267, 408, 267, 7523, 626, 314, 1526, 4046, 367, 282, 922, 2737, 315, 314, 2011, 1056, 267, 911, 1736, 6657, 14, 267, 408, 267, 327, 1666, 12052, 327, 709, 13730, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 4352, 894, 75, 344, 297, 283, 396, 19, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 267, 10157, 17, 275, 299, 16, 14, 1875, 63, 1418, 8, 751, 9, 267, 13101, 275, 2876, 14, 1462, 14, 362, 8, 2473, 534, 4352, 894, 75, 344, 358, 267, 10157, 18, 275, 299, 16, 14, 1875, 63, 1418, 8, 9233, 9, 267, 291, 14, 629, 8, 2663, 17, 12, 10157, 18, 9, 339, 347, 511, 63, 2593, 8, 277, 304, 267, 408, 267, 7523, 781, 883, 675, 314, 1526, 2410, 302, 7609, 12, 1325, 949, 8932, 14, 267, 408, 267, 327, 14911, 282, 16991, 1015, 402, 13635, 9637, 3264, 7599, 880, 781, 883, 1570, 267, 327, 314, 574, 402, 283, 8136, 7, 267, 1021, 4420, 379, 8, 6139, 9637, 3264, 7599, 304, 288, 347, 636, 826, 721, 277, 12, 11168, 304, 355, 291, 423, 8136, 63, 637, 275, 11168, 953, 347, 485, 8136, 8, 277, 304, 355, 372, 291, 423, 8136, 63, 637, 398, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 1418, 21029, 297, 283, 396, 18, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 267, 10157, 17, 275, 299, 16, 14, 1875, 63, 1418, 8, 751, 9, 267, 299, 17, 275, 4420, 379, 8, 602, 14, 8136, 342, 435, 6871, 8, 1751, 14, 9032, 63, 18066, 63, 8899, 63, 25683, 430, 267, 291, 14, 1815, 8, 80, 17, 14, 1074, 63, 1418, 8, 751, 12, 10157, 17, 430, 398, 299, 18, 275, 4420, 379, 8, 602, 14, 8136, 342, 435, 6871, 8, 1751, 14, 9032, 63, 18066, 63, 8899, 63, 25683, 435, 413, 430, 267, 291, 14, 3334, 8, 80, 18, 14, 1074, 63, 1418, 8, 751, 12, 10157, 17, 430, 339, 768, 2796, 14, 15118, 8, 1274, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 378, 395, 298, 1358, 17927, 511, 543, 2018, 650, 531, 272, 347, 511, 63, 602, 63, 1267, 8, 277, 304, 267, 408, 267, 4155, 3238, 781, 2793, 1133, 2040, 1806, 590, 1846, 10831, 12, 25498, 282, 12330, 4226, 51, 14, 267, 408, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 11744, 969, 1401, 72, 20, 88, 16, 82, 297, 283, 396, 20, 32, 2694, 14, 957, 297, 283, 80, 20, 385, 87, 16, 6883, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 398, 327, 961, 911, 5324, 282, 4329, 13, 8573, 1300, 1344, 4913, 1901, 314, 1526, 12, 1314, 365, 4634, 7031, 14, 267, 291, 14, 1855, 8, 3393, 12, 2079, 299, 16, 423, 1875, 63, 1418, 63, 1045, 63, 3954, 12, 2079, 922, 12, 5557, 1477, 1229, 1887, 10078, 10233, 11775, 969, 1887, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 492, 1434, 12, 6871, 199, 646, 984, 199, 646, 2882, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4504, 492, 13635, 9637, 3264, 7599, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 396, 492, 7640, 421, 199, 32, 15118, 31482, 199, 533, 8767, 7599, 774, 8, 1746, 304, 339, 347, 511, 63, 1875, 63, 1418, 8, 277, 304, 267, 408, 267, 7523, 626, 781, 883, 1852, 282, 1526, 436, 626, 652, 365, 1686, 267, 408, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 1418, 21029, 297, 283, 396, 18, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 267, 10157, 17, 275, 299, 16, 14, 1875, 63, 1418, 8, 751, 9, 267, 291, 14, 1815, 8, 80, 16, 14, 1074, 63, 1418, 8, 751, 12, 10157, 17, 430, 339, 347, 511, 63, 709, 13730, 8, 277, 304, 267, 408, 267, 7523, 626, 314, 1526, 4046, 367, 282, 922, 2737, 315, 314, 2011, 1056, 267, 911, 1736, 6657, 14, 267, 408, 267, 327, 1666, 12052, 327, 709, 13730, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 4352, 894, 75, 344, 297, 283, 396, 19, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 267, 10157, 17, 275, 299, 16, 14, 1875, 63, 1418, 8, 751, 9, 267, 13101, 275, 2876, 14, 1462, 14, 362, 8, 2473, 534, 4352, 894, 75, 344, 358, 267, 10157, 18, 275, 299, 16, 14, 1875, 63, 1418, 8, 9233, 9, 267, 291, 14, 629, 8, 2663, 17, 12, 10157, 18, 9, 339, 347, 511, 63, 2593, 8, 277, 304, 267, 408, 267, 7523, 781, 883, 675, 314, 1526, 2410, 302, 7609, 12, 1325, 949, 8932, 14, 267, 408, 267, 327, 14911, 282, 16991, 1015, 402, 13635, 9637, 3264, 7599, 880, 781, 883, 1570, 267, 327, 314, 574, 402, 283, 8136, 7, 267, 1021, 4420, 379, 8, 6139, 9637, 3264, 7599, 304, 288, 347, 636, 826, 721, 277, 12, 11168, 304, 355, 291, 423, 8136, 63, 637, 275, 11168, 953, 347, 485, 8136, 8, 277, 304, 355, 372, 291, 423, 8136, 63, 637, 398, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 1418, 21029, 297, 283, 396, 18, 32, 2694, 14, 957, 297, 283, 396, 8796, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 267, 10157, 17, 275, 299, 16, 14, 1875, 63, 1418, 8, 751, 9, 267, 299, 17, 275, 4420, 379, 8, 602, 14, 8136, 342, 435, 6871, 8, 1751, 14, 9032, 63, 18066, 63, 8899, 63, 25683, 430, 267, 291, 14, 1815, 8, 80, 17, 14, 1074, 63, 1418, 8, 751, 12, 10157, 17, 430, 398, 299, 18, 275, 4420, 379, 8, 602, 14, 8136, 342, 435, 6871, 8, 1751, 14, 9032, 63, 18066, 63, 8899, 63, 25683, 435, 413, 430, 267, 291, 14, 3334, 8, 80, 18, 14, 1074, 63, 1418, 8, 751, 12, 10157, 17, 430, 339, 768, 2796, 14, 15118, 8, 1274, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 378, 395, 298, 1358, 17927, 511, 543, 2018, 650, 531, 272, 347, 511, 63, 602, 63, 1267, 8, 277, 304, 267, 408, 267, 4155, 3238, 781, 2793, 1133, 2040, 1806, 590, 1846, 10831, 12, 25498, 282, 12330, 4226, 51, 14, 267, 408, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 360, 11744, 969, 1401, 72, 20, 88, 16, 82, 297, 283, 396, 20, 32, 2694, 14, 957, 297, 283, 80, 20, 385, 87, 16, 6883, 358, 267, 299, 16, 275, 13635, 9637, 3264, 7599, 342, 398, 327, 961, 911, 5324, 282, 4329, 13, 8573, 1300, 1344, 4913, 1901, 314, 1526, 12, 1314, 365, 4634, 7031, 14, 267, 291, 14, 1855, 8, 3393, 12, 2079, 299, 16, 423, 1875, 63, 1418, 63, 1045, 63, 3954, 12, 2079, 922, 12, 5557, 1477, 1229, 1887, 10078, 10233, 11775, 969, 1887, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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/near_duplicates.py
1
6806
import geohash import logging import operator from functools import partial from itertools import chain, product, combinations, imap from address_normalizer.deduping.duplicates import * from address_normalizer.deduping.storage.base import * from address_normalizer.text.gazetteers import * from address_normalizer.text.normalize import * from address_normalizer.models.address import * from address_normalizer.models.venue import * near_dupe_registry = {} # Two lat/longs sharing a geohash prefix of 6 characters are within about 610 meters of each other DEFAULT_GEOHASH_PRECISION = 6 logger = logging.getLogger('near_dupes') class NearDupeMeta(type): def __init__(cls, name, bases, dict_): if 'abstract' not in dict_: near_dupe_registry[cls.__entity_type__] = cls super(NearDupeMeta, cls).__init__(name, bases, dict_) dupe_cache = {} class NearDupe(object): abstract = True __metaclass__ = NearDupeMeta key_generators = () configured = False storage = NopStorage() @classmethod def configure(cls, storage): cls.storage = storage @classmethod def find_dupes(cls, ents): if not ents: return {}, {}, {} entity_dict = {e.guid: e for e in ents} clusters = defaultdict(set) _ = [clusters[safe_encode(c)].add(ent.guid) for ent in ents for c in cls.gen_keys(ent)] clusters = dict(clusters) logger.info('{} clusters found'.format(len(clusters))) logger.info('Checking for local dupes') local_guid_pairs = set() local_dupes = {} for cluster_id, guids in clusters.iteritems(): if len(guids) < 2: continue local_guid_pairs.update(combinations(guids, 2)) for g1, g2 in local_guid_pairs: ent1 = entity_dict[g1] ent2 = entity_dict[g2] if cls.exact_dupe.is_dupe(ent1, ent2): cls.assign_local_dupe(local_dupes, ent1, ent2) logger.info('Checking global dupes') existing_clusters = defaultdict(list) if clusters: _ = [existing_clusters[c].append(guid) for c, guid in cls.storage.search(clusters.keys()).iteritems() if guid] existing_guids = set() existing_ents = {} if existing_clusters: existing_guids = set.union(*(set(v) for v in existing_clusters.itervalues())) existing_ents = {guid: cls.model(json.loads(e)) for guid, e in cls.storage.multiget(list(existing_guids)).iteritems() if e} global_dupes = {} global_guid_pairs = set([(new_guid, existing_guid) for cluster_id, existing in existing_clusters.iteritems() for new_guid, existing_guid in product(clusters[cluster_id], existing)]) for new_guid, existing_guid in global_guid_pairs: local_ent = entity_dict[new_guid] existing_ent = existing_ents[existing_guid] if cls.exact_dupe.is_dupe(existing_ent, local_ent): cls.assign_global_dupe(global_dupes, existing_ent, local_ent) logger.info('Done with global dupe checking') return clusters, local_dupes, global_dupes @classmethod def check(cls, objects, add=True): object_dict = {o.guid: o for o in objects} clusters, local_dupes, global_dupes = cls.find_dupes(objects) new_clusters = {} new_objects = {} dupes = local_dupes.copy() dupes.update(global_dupes) if add: for k, guids in clusters.iteritems(): non_dupes = [g for g in guids if g not in dupes] if non_dupes: guid = non_dupes[0] new_clusters[k] = guid new_objects[guid] = object_dict[guid] cls.add({guid: json.dumps(obj.to_primitive()) for guid, obj in new_objects.iteritems()}) cls.add_clusters(new_clusters) return [(obj, (dupes.get(obj.guid, obj.guid), obj.guid in dupes)) for obj in objects] @classmethod def assign_local_dupe(cls, dupes, existing, new): guid1 = existing.guid guid2 = new.guid guid1_existing = dupes.get(guid1) guid2_existing = dupes.get(guid2) if not guid1_existing and not guid2_existing: dupes[guid1] = guid2 elif guid1_existing: dupes[guid2] = guid1_existing elif guid2_existing: dupes[guid1] = guid2_existing @classmethod def assign_global_dupe(cls, dupes, existing, new): dupes[new.guid] = existing.guid @classmethod def add(cls, kvs): cls.storage.multiput(kvs) @classmethod def add_clusters(cls, kvs): cls.storage.multiput(kvs) class AddressNearDupe(NearDupe): __entity_type__ = Address.entity_type model = Address exact_dupe = AddressDupe geohash_precision = DEFAULT_GEOHASH_PRECISION street_gazetteers = list(chain(*[gazette_field_registry[f] for f in (address_fields.NAME, address_fields.HOUSE_NUMBER, address_fields.STREET)])) all_gazetteers = list(chain(*gazette_field_registry.values())) @classmethod def configure(cls, storage, bloom_filter=None, geohash_precision=DEFAULT_GEOHASH_PRECISION): cls.storage = storage if bloom_filter: cls.bloom_filter = bloom_filter cls.geohash_precision = geohash_precision @classmethod def expanded_street_address(cls, address): street_address_components = [] house_number = (address.house_number or '').strip() if house_number: street_address_components.append(house_number) street = (address.street or '').strip() if street: street_address_components.append(street) surface_forms = set() if street_address_components: street_address = u' '.join(street_address_components) # the return value from expand return address_phrase_filter.expand_street_address(street_address) @classmethod def geohash(cls, address): geo = geohash.encode(address.latitude, address.longitude, cls.geohash_precision) neighbors = geohash.neighbors(geo) all_geo = [geo] + neighbors return all_geo @classmethod def gen_keys(cls, address): street_surface_forms = cls.expanded_street_address(address) if address.latitude and address.longitude: all_geo = cls.geohash(address) for geo, norm_address in product(all_geo, street_surface_forms): key = '|'.join([geo, norm_address]) yield key class VenueNearDupe(NearDupe): __entity_type__ = Venue.entity_type model = Venue
mit
[ 646, 8509, 2227, 199, 646, 2050, 199, 199, 646, 4182, 199, 199, 504, 9143, 492, 7417, 199, 199, 504, 7975, 492, 6036, 12, 3336, 12, 15821, 12, 23646, 199, 199, 504, 2287, 63, 3302, 1793, 14, 770, 384, 316, 14, 18563, 492, 627, 199, 504, 2287, 63, 3302, 1793, 14, 770, 384, 316, 14, 3494, 14, 1095, 492, 627, 199, 199, 504, 2287, 63, 3302, 1793, 14, 505, 14, 71, 4651, 386, 266, 1192, 492, 627, 199, 504, 2287, 63, 3302, 1793, 14, 505, 14, 7721, 492, 627, 199, 199, 504, 2287, 63, 3302, 1793, 14, 992, 14, 1562, 492, 627, 199, 504, 2287, 63, 3302, 1793, 14, 992, 14, 24728, 492, 627, 199, 199, 21078, 63, 30706, 63, 5189, 275, 1052, 199, 199, 3, 16853, 8396, 15, 5298, 458, 26994, 282, 8509, 2227, 2403, 402, 1227, 4110, 787, 4453, 3595, 1227, 709, 24808, 402, 1924, 1163, 199, 3472, 63, 18120, 14395, 63, 14246, 30011, 275, 1227, 199, 199, 2921, 275, 2050, 14, 5572, 360, 21078, 63, 2033, 22020, 358, 199, 199, 533, 653, 2210, 36, 85, 321, 3396, 8, 466, 304, 272, 347, 636, 826, 721, 1886, 12, 536, 12, 9768, 12, 1211, 7822, 267, 340, 283, 6198, 7, 440, 315, 1211, 10388, 288, 17429, 63, 30706, 63, 5189, 59, 1886, 855, 4502, 63, 466, 22705, 275, 843, 10631, 1613, 8, 46, 2210, 36, 85, 321, 3396, 12, 843, 2843, 826, 721, 354, 12, 9768, 12, 1211, 4602, 339, 15776, 321, 63, 1637, 275, 1052, 421, 199, 533, 653, 2210, 36, 85, 321, 8, 785, 304, 272, 9006, 275, 715, 272, 636, 6577, 363, 275, 653, 2210, 36, 85, 321, 3396, 2286, 790, 63, 20748, 275, 6248, 2286, 7526, 275, 756, 272, 4887, 275, 653, 411, 6408, 342, 339, 768, 3744, 272, 347, 7908, 8, 1886, 12, 4887, 304, 267, 843, 14, 3494, 275, 4887, 339, 768, 3744, 272, 347, 2342, 63, 2033, 22020, 8, 1886, 12, 15992, 83, 304, 267, 340, 440, 15992, 83, 26, 288, 372, 5479, 5479, 1052, 2728, 4642, 63, 807, 275, 469, 69, 14, 9473, 26, 325, 367, 325, 315, 15992, 83, 93, 267, 13865, 275, 10018, 8, 409, 9, 267, 485, 275, 359, 9170, 59, 3489, 63, 2143, 8, 67, 22509, 525, 8, 484, 14, 9473, 9, 367, 15992, 315, 15992, 83, 367, 286, 315, 843, 14, 2268, 63, 1612, 8, 484, 1874, 267, 13865, 275, 1211, 8, 9170, 9, 267, 2512, 14, 815, 17519, 13865, 1911, 1370, 908, 8, 552, 8, 9170, 1724, 2728, 2512, 14, 815, 360, 14740, 367, 2257, 15776, 22020, 358, 398, 2257, 63, 9473, 63, 7322, 275, 663, 342, 267, 2257, 63, 2033, 22020, 275, 1052, 398, 367, 4350, 63, 344, 12, 15593, 83, 315, 13865, 14, 4611, 837, 288, 340, 822, 8, 9473, 83, 9, 665, 499, 26, 355, 1980, 953, 2257, 63, 9473, 63, 7322, 14, 873, 8, 18026, 8, 9473, 83, 12, 499, 430, 398, 367, 486, 17, 12, 486, 18, 315, 2257, 63, 9473, 63, 7322, 26, 288, 15992, 17, 275, 4642, 63, 807, 59, 71, 17, 61, 288, 15992, 18, 275, 4642, 63, 807, 59, 71, 18, 61, 288, 340, 843, 14, 7327, 63, 30706, 14, 374, 63, 30706, 8, 484, 17, 12, 15992, 18, 304, 355, 843, 14, 5038, 63, 1832, 63, 30706, 8, 1832, 63, 2033, 22020, 12, 15992, 17, 12, 15992, 18, 9, 2728, 2512, 14, 815, 360, 14740, 2288, 15776, 22020, 358, 398, 3411, 63, 9170, 275, 10018, 8, 513, 9, 398, 340, 13865, 26, 288, 485, 275, 359, 5952, 63, 9170, 59, 67, 1055, 740, 8, 9473, 9, 367, 286, 12, 15593, 315, 843, 14, 3494, 14, 1733, 8, 9170, 14, 1612, 8801, 4611, 342, 340, 15593, 61, 398, 3411, 63, 9473, 83, 275, 663, 342, 267, 3411, 63, 24871, 275, 1052, 2728, 340, 3411, 63, 9170, 26, 288, 3411, 63, 9473, 83, 275, 663, 14, 8888, 29316, 409, 8, 86, 9, 367, 373, 315, 3411, 63, 9170, 14, 13012, 4059, 288, 3411, 63, 24871, 275, 469, 9473, 26, 843, 14, 1238, 8, 1001, 14, 3640, 8, 69, 430, 367, 15593, 12, 325, 315, 843, 14, 3494, 14, 3029, 362, 8, 513, 8, 5952, 63, 9473, 83, 4992, 4611, 342, 340, 325, 93, 288, 267, 2288, 63, 2033, 22020, 275, 1052, 398, 2288, 63, 9473, 63, 7322, 275, 663, 7694, 1222, 63, 9473, 12, 3411, 63, 9473, 9, 367, 4350, 63, 344, 12, 3411, 315, 3411, 63, 9170, 14, 4611, 342, 367, 892, 63, 9473, 12, 3411, 63, 9473, 315, 3336, 8, 9170, 59, 4201, 63, 344, 467, 3411, 3948, 2728, 367, 892, 63, 9473, 12, 3411, 63, 9473, 315, 2288, 63, 9473, 63, 7322, 26, 288, 2257, 63, 484, 275, 4642, 63, 807, 59, 1222, 63, 9473, 61, 288, 3411, 63, 484, 275, 3411, 63, 24871, 59, 5952, 63, 9473, 61, 288, 340, 843, 14, 7327, 63, 30706, 14, 374, 63, 30706, 8, 5952, 63, 484, 12, 2257, 63, 484, 304, 355, 843, 14, 5038, 63, 2966, 63, 30706, 8, 2966, 63, 2033, 22020, 12, 3411, 63, 484, 12, 2257, 63, 484, 9, 398, 2512, 14, 815, 360, 10759, 543, 2288, 15776, 321, 7907, 358, 27144, 372, 13865, 12, 2257, 63, 2033, 22020, 12, 2288, 63, 2033, 22020, 339, 768, 3744, 272, 347, 1104, 8, 1886, 12, 2251, 12, 1050, 29, 549, 304, 267, 909, 63, 807, 275, 469, 79, 14, 9473, 26, 312, 367, 312, 315, 2251, 93, 267, 13865, 12, 2257, 63, 2033, 22020, 12, 2288, 63, 2033, 22020, 275, 843, 14, 1623, 63, 2033, 22020, 8, 1462, 9, 398, 892, 63, 9170, 275, 1052, 267, 892, 63, 1462, 275, 1052, 398, 15776, 22020, 275, 2257, 63, 2033, 22020, 14, 1574, 342, 267, 15776, 22020, 14, 873, 8, 2966, 63, 2033, 22020, 9, 398, 340, 1050, 26, 288, 367, 1022, 12, 15593, 83, 315, 13865, 14, 4611, 837, 355, 2222, 63, 2033, 22020, 275, 359, 71, 367, 486, 315, 15593, 83, 340, 486, 440, 315, 15776, 22020, 61, 355, 340, 2222, 63, 2033, 22020, 26, 490, 15593, 275, 2222, 63, 2033, 22020, 59, 16, 61, 490, 892, 63, 9170, 59, 75, 61, 275, 15593, 490, 892, 63, 1462, 59, 9473, 61, 275, 909, 63, 807, 59, 9473, 61, 953 ]
[ 8509, 2227, 199, 646, 2050, 199, 199, 646, 4182, 199, 199, 504, 9143, 492, 7417, 199, 199, 504, 7975, 492, 6036, 12, 3336, 12, 15821, 12, 23646, 199, 199, 504, 2287, 63, 3302, 1793, 14, 770, 384, 316, 14, 18563, 492, 627, 199, 504, 2287, 63, 3302, 1793, 14, 770, 384, 316, 14, 3494, 14, 1095, 492, 627, 199, 199, 504, 2287, 63, 3302, 1793, 14, 505, 14, 71, 4651, 386, 266, 1192, 492, 627, 199, 504, 2287, 63, 3302, 1793, 14, 505, 14, 7721, 492, 627, 199, 199, 504, 2287, 63, 3302, 1793, 14, 992, 14, 1562, 492, 627, 199, 504, 2287, 63, 3302, 1793, 14, 992, 14, 24728, 492, 627, 199, 199, 21078, 63, 30706, 63, 5189, 275, 1052, 199, 199, 3, 16853, 8396, 15, 5298, 458, 26994, 282, 8509, 2227, 2403, 402, 1227, 4110, 787, 4453, 3595, 1227, 709, 24808, 402, 1924, 1163, 199, 3472, 63, 18120, 14395, 63, 14246, 30011, 275, 1227, 199, 199, 2921, 275, 2050, 14, 5572, 360, 21078, 63, 2033, 22020, 358, 199, 199, 533, 653, 2210, 36, 85, 321, 3396, 8, 466, 304, 272, 347, 636, 826, 721, 1886, 12, 536, 12, 9768, 12, 1211, 7822, 267, 340, 283, 6198, 7, 440, 315, 1211, 10388, 288, 17429, 63, 30706, 63, 5189, 59, 1886, 855, 4502, 63, 466, 22705, 275, 843, 10631, 1613, 8, 46, 2210, 36, 85, 321, 3396, 12, 843, 2843, 826, 721, 354, 12, 9768, 12, 1211, 4602, 339, 15776, 321, 63, 1637, 275, 1052, 421, 199, 533, 653, 2210, 36, 85, 321, 8, 785, 304, 272, 9006, 275, 715, 272, 636, 6577, 363, 275, 653, 2210, 36, 85, 321, 3396, 2286, 790, 63, 20748, 275, 6248, 2286, 7526, 275, 756, 272, 4887, 275, 653, 411, 6408, 342, 339, 768, 3744, 272, 347, 7908, 8, 1886, 12, 4887, 304, 267, 843, 14, 3494, 275, 4887, 339, 768, 3744, 272, 347, 2342, 63, 2033, 22020, 8, 1886, 12, 15992, 83, 304, 267, 340, 440, 15992, 83, 26, 288, 372, 5479, 5479, 1052, 2728, 4642, 63, 807, 275, 469, 69, 14, 9473, 26, 325, 367, 325, 315, 15992, 83, 93, 267, 13865, 275, 10018, 8, 409, 9, 267, 485, 275, 359, 9170, 59, 3489, 63, 2143, 8, 67, 22509, 525, 8, 484, 14, 9473, 9, 367, 15992, 315, 15992, 83, 367, 286, 315, 843, 14, 2268, 63, 1612, 8, 484, 1874, 267, 13865, 275, 1211, 8, 9170, 9, 267, 2512, 14, 815, 17519, 13865, 1911, 1370, 908, 8, 552, 8, 9170, 1724, 2728, 2512, 14, 815, 360, 14740, 367, 2257, 15776, 22020, 358, 398, 2257, 63, 9473, 63, 7322, 275, 663, 342, 267, 2257, 63, 2033, 22020, 275, 1052, 398, 367, 4350, 63, 344, 12, 15593, 83, 315, 13865, 14, 4611, 837, 288, 340, 822, 8, 9473, 83, 9, 665, 499, 26, 355, 1980, 953, 2257, 63, 9473, 63, 7322, 14, 873, 8, 18026, 8, 9473, 83, 12, 499, 430, 398, 367, 486, 17, 12, 486, 18, 315, 2257, 63, 9473, 63, 7322, 26, 288, 15992, 17, 275, 4642, 63, 807, 59, 71, 17, 61, 288, 15992, 18, 275, 4642, 63, 807, 59, 71, 18, 61, 288, 340, 843, 14, 7327, 63, 30706, 14, 374, 63, 30706, 8, 484, 17, 12, 15992, 18, 304, 355, 843, 14, 5038, 63, 1832, 63, 30706, 8, 1832, 63, 2033, 22020, 12, 15992, 17, 12, 15992, 18, 9, 2728, 2512, 14, 815, 360, 14740, 2288, 15776, 22020, 358, 398, 3411, 63, 9170, 275, 10018, 8, 513, 9, 398, 340, 13865, 26, 288, 485, 275, 359, 5952, 63, 9170, 59, 67, 1055, 740, 8, 9473, 9, 367, 286, 12, 15593, 315, 843, 14, 3494, 14, 1733, 8, 9170, 14, 1612, 8801, 4611, 342, 340, 15593, 61, 398, 3411, 63, 9473, 83, 275, 663, 342, 267, 3411, 63, 24871, 275, 1052, 2728, 340, 3411, 63, 9170, 26, 288, 3411, 63, 9473, 83, 275, 663, 14, 8888, 29316, 409, 8, 86, 9, 367, 373, 315, 3411, 63, 9170, 14, 13012, 4059, 288, 3411, 63, 24871, 275, 469, 9473, 26, 843, 14, 1238, 8, 1001, 14, 3640, 8, 69, 430, 367, 15593, 12, 325, 315, 843, 14, 3494, 14, 3029, 362, 8, 513, 8, 5952, 63, 9473, 83, 4992, 4611, 342, 340, 325, 93, 288, 267, 2288, 63, 2033, 22020, 275, 1052, 398, 2288, 63, 9473, 63, 7322, 275, 663, 7694, 1222, 63, 9473, 12, 3411, 63, 9473, 9, 367, 4350, 63, 344, 12, 3411, 315, 3411, 63, 9170, 14, 4611, 342, 367, 892, 63, 9473, 12, 3411, 63, 9473, 315, 3336, 8, 9170, 59, 4201, 63, 344, 467, 3411, 3948, 2728, 367, 892, 63, 9473, 12, 3411, 63, 9473, 315, 2288, 63, 9473, 63, 7322, 26, 288, 2257, 63, 484, 275, 4642, 63, 807, 59, 1222, 63, 9473, 61, 288, 3411, 63, 484, 275, 3411, 63, 24871, 59, 5952, 63, 9473, 61, 288, 340, 843, 14, 7327, 63, 30706, 14, 374, 63, 30706, 8, 5952, 63, 484, 12, 2257, 63, 484, 304, 355, 843, 14, 5038, 63, 2966, 63, 30706, 8, 2966, 63, 2033, 22020, 12, 3411, 63, 484, 12, 2257, 63, 484, 9, 398, 2512, 14, 815, 360, 10759, 543, 2288, 15776, 321, 7907, 358, 27144, 372, 13865, 12, 2257, 63, 2033, 22020, 12, 2288, 63, 2033, 22020, 339, 768, 3744, 272, 347, 1104, 8, 1886, 12, 2251, 12, 1050, 29, 549, 304, 267, 909, 63, 807, 275, 469, 79, 14, 9473, 26, 312, 367, 312, 315, 2251, 93, 267, 13865, 12, 2257, 63, 2033, 22020, 12, 2288, 63, 2033, 22020, 275, 843, 14, 1623, 63, 2033, 22020, 8, 1462, 9, 398, 892, 63, 9170, 275, 1052, 267, 892, 63, 1462, 275, 1052, 398, 15776, 22020, 275, 2257, 63, 2033, 22020, 14, 1574, 342, 267, 15776, 22020, 14, 873, 8, 2966, 63, 2033, 22020, 9, 398, 340, 1050, 26, 288, 367, 1022, 12, 15593, 83, 315, 13865, 14, 4611, 837, 355, 2222, 63, 2033, 22020, 275, 359, 71, 367, 486, 315, 15593, 83, 340, 486, 440, 315, 15776, 22020, 61, 355, 340, 2222, 63, 2033, 22020, 26, 490, 15593, 275, 2222, 63, 2033, 22020, 59, 16, 61, 490, 892, 63, 9170, 59, 75, 61, 275, 15593, 490, 892, 63, 1462, 59, 9473, 61, 275, 909, 63, 807, 59, 9473, 61,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1, 1, 1, 1 ]
magicrub/MissionPlanner
Lib/encodings/iso8859_8.py
93
11599
""" Python Character Mapping Codec iso8859_8 generated from 'MAPPINGS/ISO8859/8859-8.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_table)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='iso8859-8', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Table decoding_table = ( u'\x00' # 0x00 -> NULL u'\x01' # 0x01 -> START OF HEADING u'\x02' # 0x02 -> START OF TEXT u'\x03' # 0x03 -> END OF TEXT u'\x04' # 0x04 -> END OF TRANSMISSION u'\x05' # 0x05 -> ENQUIRY u'\x06' # 0x06 -> ACKNOWLEDGE u'\x07' # 0x07 -> BELL u'\x08' # 0x08 -> BACKSPACE u'\t' # 0x09 -> HORIZONTAL TABULATION u'\n' # 0x0A -> LINE FEED u'\x0b' # 0x0B -> VERTICAL TABULATION u'\x0c' # 0x0C -> FORM FEED u'\r' # 0x0D -> CARRIAGE RETURN u'\x0e' # 0x0E -> SHIFT OUT u'\x0f' # 0x0F -> SHIFT IN u'\x10' # 0x10 -> DATA LINK ESCAPE u'\x11' # 0x11 -> DEVICE CONTROL ONE u'\x12' # 0x12 -> DEVICE CONTROL TWO u'\x13' # 0x13 -> DEVICE CONTROL THREE u'\x14' # 0x14 -> DEVICE CONTROL FOUR u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x16 -> SYNCHRONOUS IDLE u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK u'\x18' # 0x18 -> CANCEL u'\x19' # 0x19 -> END OF MEDIUM u'\x1a' # 0x1A -> SUBSTITUTE u'\x1b' # 0x1B -> ESCAPE u'\x1c' # 0x1C -> FILE SEPARATOR u'\x1d' # 0x1D -> GROUP SEPARATOR u'\x1e' # 0x1E -> RECORD SEPARATOR u'\x1f' # 0x1F -> UNIT SEPARATOR u' ' # 0x20 -> SPACE u'!' # 0x21 -> EXCLAMATION MARK u'"' # 0x22 -> QUOTATION MARK u'#' # 0x23 -> NUMBER SIGN u'$' # 0x24 -> DOLLAR SIGN u'%' # 0x25 -> PERCENT SIGN u'&' # 0x26 -> AMPERSAND u"'" # 0x27 -> APOSTROPHE u'(' # 0x28 -> LEFT PARENTHESIS u')' # 0x29 -> RIGHT PARENTHESIS u'*' # 0x2A -> ASTERISK u'+' # 0x2B -> PLUS SIGN u',' # 0x2C -> COMMA u'-' # 0x2D -> HYPHEN-MINUS u'.' # 0x2E -> FULL STOP u'/' # 0x2F -> SOLIDUS u'0' # 0x30 -> DIGIT ZERO u'1' # 0x31 -> DIGIT ONE u'2' # 0x32 -> DIGIT TWO u'3' # 0x33 -> DIGIT THREE u'4' # 0x34 -> DIGIT FOUR u'5' # 0x35 -> DIGIT FIVE u'6' # 0x36 -> DIGIT SIX u'7' # 0x37 -> DIGIT SEVEN u'8' # 0x38 -> DIGIT EIGHT u'9' # 0x39 -> DIGIT NINE u':' # 0x3A -> COLON u';' # 0x3B -> SEMICOLON u'<' # 0x3C -> LESS-THAN SIGN u'=' # 0x3D -> EQUALS SIGN u'>' # 0x3E -> GREATER-THAN SIGN u'?' # 0x3F -> QUESTION MARK u'@' # 0x40 -> COMMERCIAL AT u'A' # 0x41 -> LATIN CAPITAL LETTER A u'B' # 0x42 -> LATIN CAPITAL LETTER B u'C' # 0x43 -> LATIN CAPITAL LETTER C u'D' # 0x44 -> LATIN CAPITAL LETTER D u'E' # 0x45 -> LATIN CAPITAL LETTER E u'F' # 0x46 -> LATIN CAPITAL LETTER F u'G' # 0x47 -> LATIN CAPITAL LETTER G u'H' # 0x48 -> LATIN CAPITAL LETTER H u'I' # 0x49 -> LATIN CAPITAL LETTER I u'J' # 0x4A -> LATIN CAPITAL LETTER J u'K' # 0x4B -> LATIN CAPITAL LETTER K u'L' # 0x4C -> LATIN CAPITAL LETTER L u'M' # 0x4D -> LATIN CAPITAL LETTER M u'N' # 0x4E -> LATIN CAPITAL LETTER N u'O' # 0x4F -> LATIN CAPITAL LETTER O u'P' # 0x50 -> LATIN CAPITAL LETTER P u'Q' # 0x51 -> LATIN CAPITAL LETTER Q u'R' # 0x52 -> LATIN CAPITAL LETTER R u'S' # 0x53 -> LATIN CAPITAL LETTER S u'T' # 0x54 -> LATIN CAPITAL LETTER T u'U' # 0x55 -> LATIN CAPITAL LETTER U u'V' # 0x56 -> LATIN CAPITAL LETTER V u'W' # 0x57 -> LATIN CAPITAL LETTER W u'X' # 0x58 -> LATIN CAPITAL LETTER X u'Y' # 0x59 -> LATIN CAPITAL LETTER Y u'Z' # 0x5A -> LATIN CAPITAL LETTER Z u'[' # 0x5B -> LEFT SQUARE BRACKET u'\\' # 0x5C -> REVERSE SOLIDUS u']' # 0x5D -> RIGHT SQUARE BRACKET u'^' # 0x5E -> CIRCUMFLEX ACCENT u'_' # 0x5F -> LOW LINE u'`' # 0x60 -> GRAVE ACCENT u'a' # 0x61 -> LATIN SMALL LETTER A u'b' # 0x62 -> LATIN SMALL LETTER B u'c' # 0x63 -> LATIN SMALL LETTER C u'd' # 0x64 -> LATIN SMALL LETTER D u'e' # 0x65 -> LATIN SMALL LETTER E u'f' # 0x66 -> LATIN SMALL LETTER F u'g' # 0x67 -> LATIN SMALL LETTER G u'h' # 0x68 -> LATIN SMALL LETTER H u'i' # 0x69 -> LATIN SMALL LETTER I u'j' # 0x6A -> LATIN SMALL LETTER J u'k' # 0x6B -> LATIN SMALL LETTER K u'l' # 0x6C -> LATIN SMALL LETTER L u'm' # 0x6D -> LATIN SMALL LETTER M u'n' # 0x6E -> LATIN SMALL LETTER N u'o' # 0x6F -> LATIN SMALL LETTER O u'p' # 0x70 -> LATIN SMALL LETTER P u'q' # 0x71 -> LATIN SMALL LETTER Q u'r' # 0x72 -> LATIN SMALL LETTER R u's' # 0x73 -> LATIN SMALL LETTER S u't' # 0x74 -> LATIN SMALL LETTER T u'u' # 0x75 -> LATIN SMALL LETTER U u'v' # 0x76 -> LATIN SMALL LETTER V u'w' # 0x77 -> LATIN SMALL LETTER W u'x' # 0x78 -> LATIN SMALL LETTER X u'y' # 0x79 -> LATIN SMALL LETTER Y u'z' # 0x7A -> LATIN SMALL LETTER Z u'{' # 0x7B -> LEFT CURLY BRACKET u'|' # 0x7C -> VERTICAL LINE u'}' # 0x7D -> RIGHT CURLY BRACKET u'~' # 0x7E -> TILDE u'\x7f' # 0x7F -> DELETE u'\x80' # 0x80 -> <control> u'\x81' # 0x81 -> <control> u'\x82' # 0x82 -> <control> u'\x83' # 0x83 -> <control> u'\x84' # 0x84 -> <control> u'\x85' # 0x85 -> <control> u'\x86' # 0x86 -> <control> u'\x87' # 0x87 -> <control> u'\x88' # 0x88 -> <control> u'\x89' # 0x89 -> <control> u'\x8a' # 0x8A -> <control> u'\x8b' # 0x8B -> <control> u'\x8c' # 0x8C -> <control> u'\x8d' # 0x8D -> <control> u'\x8e' # 0x8E -> <control> u'\x8f' # 0x8F -> <control> u'\x90' # 0x90 -> <control> u'\x91' # 0x91 -> <control> u'\x92' # 0x92 -> <control> u'\x93' # 0x93 -> <control> u'\x94' # 0x94 -> <control> u'\x95' # 0x95 -> <control> u'\x96' # 0x96 -> <control> u'\x97' # 0x97 -> <control> u'\x98' # 0x98 -> <control> u'\x99' # 0x99 -> <control> u'\x9a' # 0x9A -> <control> u'\x9b' # 0x9B -> <control> u'\x9c' # 0x9C -> <control> u'\x9d' # 0x9D -> <control> u'\x9e' # 0x9E -> <control> u'\x9f' # 0x9F -> <control> u'\xa0' # 0xA0 -> NO-BREAK SPACE u'\ufffe' u'\xa2' # 0xA2 -> CENT SIGN u'\xa3' # 0xA3 -> POUND SIGN u'\xa4' # 0xA4 -> CURRENCY SIGN u'\xa5' # 0xA5 -> YEN SIGN u'\xa6' # 0xA6 -> BROKEN BAR u'\xa7' # 0xA7 -> SECTION SIGN u'\xa8' # 0xA8 -> DIAERESIS u'\xa9' # 0xA9 -> COPYRIGHT SIGN u'\xd7' # 0xAA -> MULTIPLICATION SIGN u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xac' # 0xAC -> NOT SIGN u'\xad' # 0xAD -> SOFT HYPHEN u'\xae' # 0xAE -> REGISTERED SIGN u'\xaf' # 0xAF -> MACRON u'\xb0' # 0xB0 -> DEGREE SIGN u'\xb1' # 0xB1 -> PLUS-MINUS SIGN u'\xb2' # 0xB2 -> SUPERSCRIPT TWO u'\xb3' # 0xB3 -> SUPERSCRIPT THREE u'\xb4' # 0xB4 -> ACUTE ACCENT u'\xb5' # 0xB5 -> MICRO SIGN u'\xb6' # 0xB6 -> PILCROW SIGN u'\xb7' # 0xB7 -> MIDDLE DOT u'\xb8' # 0xB8 -> CEDILLA u'\xb9' # 0xB9 -> SUPERSCRIPT ONE u'\xf7' # 0xBA -> DIVISION SIGN u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\ufffe' u'\u2017' # 0xDF -> DOUBLE LOW LINE u'\u05d0' # 0xE0 -> HEBREW LETTER ALEF u'\u05d1' # 0xE1 -> HEBREW LETTER BET u'\u05d2' # 0xE2 -> HEBREW LETTER GIMEL u'\u05d3' # 0xE3 -> HEBREW LETTER DALET u'\u05d4' # 0xE4 -> HEBREW LETTER HE u'\u05d5' # 0xE5 -> HEBREW LETTER VAV u'\u05d6' # 0xE6 -> HEBREW LETTER ZAYIN u'\u05d7' # 0xE7 -> HEBREW LETTER HET u'\u05d8' # 0xE8 -> HEBREW LETTER TET u'\u05d9' # 0xE9 -> HEBREW LETTER YOD u'\u05da' # 0xEA -> HEBREW LETTER FINAL KAF u'\u05db' # 0xEB -> HEBREW LETTER KAF u'\u05dc' # 0xEC -> HEBREW LETTER LAMED u'\u05dd' # 0xED -> HEBREW LETTER FINAL MEM u'\u05de' # 0xEE -> HEBREW LETTER MEM u'\u05df' # 0xEF -> HEBREW LETTER FINAL NUN u'\u05e0' # 0xF0 -> HEBREW LETTER NUN u'\u05e1' # 0xF1 -> HEBREW LETTER SAMEKH u'\u05e2' # 0xF2 -> HEBREW LETTER AYIN u'\u05e3' # 0xF3 -> HEBREW LETTER FINAL PE u'\u05e4' # 0xF4 -> HEBREW LETTER PE u'\u05e5' # 0xF5 -> HEBREW LETTER FINAL TSADI u'\u05e6' # 0xF6 -> HEBREW LETTER TSADI u'\u05e7' # 0xF7 -> HEBREW LETTER QOF u'\u05e8' # 0xF8 -> HEBREW LETTER RESH u'\u05e9' # 0xF9 -> HEBREW LETTER SHIN u'\u05ea' # 0xFA -> HEBREW LETTER TAV u'\ufffe' u'\ufffe' u'\u200e' # 0xFD -> LEFT-TO-RIGHT MARK u'\u200f' # 0xFE -> RIGHT-TO-LEFT MARK u'\ufffe' ) ### Encoding table encoding_table=codecs.charmap_build(decoding_table)
gpl-3.0
[ 624, 2018, 17660, 12340, 13732, 11601, 4830, 63, 24, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 24, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 2999, 199, 624, 23662, 2999, 199, 646, 6010, 2999, 199, 5680, 13732, 15913, 2999, 199, 533, 13732, 8, 8933, 14, 8818, 304, 2958, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 1039, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 2958, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 1039, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 2999, 199, 533, 24350, 8, 8933, 14, 17016, 304, 1128, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 2999, 199, 533, 24385, 8, 8933, 14, 16703, 304, 1128, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 2999, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 1128, 986, 2999, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 1128, 986, 2999, 199, 5680, 14134, 859, 3261, 2999, 199, 318, 26116, 837, 1128, 372, 6010, 14, 26375, 8, 1039, 536, 534, 4595, 4830, 13, 24, 297, 1039, 3752, 29, 8818, 1252, 2143, 12, 1039, 4849, 29, 8818, 1252, 2708, 12, 1039, 26329, 29, 17016, 12, 1039, 26317, 29, 16703, 12, 1039, 26101, 29, 16132, 12, 1039, 26112, 29, 16551, 12, 1128, 776, 8065, 199, 5680, 27368, 6957, 2999, 199, 12796, 63, 1224, 275, 334, 1128, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 1128, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 1128, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 1128, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 1128, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 1128, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 1128, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 1128, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 1128, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 1128, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 1128, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 1128, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 1128, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 1128, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 1128, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 1128, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 1128, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 1128, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 1128, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 1128, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 1128, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 1128, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 1128, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 1128, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 1128, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 1128, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 1128, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 1128, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 1128, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 1128, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 1128, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 1128, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 1128, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 1128, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 1128, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 1128, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 1128, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 1128, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 1128, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 1128, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 1128, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 1128, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 1128, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 1128, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 1128, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 1128, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 1128, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 1128, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 1128, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 1128, 399, 7, 17, 7, 263, 327, 221 ]
[ 2018, 17660, 12340, 13732, 11601, 4830, 63, 24, 4046, 687, 283, 32362, 15, 7336, 4830, 15, 4830, 13, 24, 14, 17715, 7, 543, 486, 2143, 67, 14, 647, 14, 2999, 199, 624, 23662, 2999, 199, 646, 6010, 2999, 199, 5680, 13732, 15913, 2999, 199, 533, 13732, 8, 8933, 14, 8818, 304, 2958, 347, 3752, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 1039, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 2550, 12, 2991, 63, 1224, 9, 2958, 347, 4849, 8, 277, 12, 1210, 12, 2550, 534, 4768, 735, 1039, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 2550, 12, 12796, 63, 1224, 9, 2999, 199, 533, 24350, 8, 8933, 14, 17016, 304, 1128, 347, 3752, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 372, 6010, 14, 13391, 63, 2143, 8, 1210, 12, 277, 14, 2550, 12, 2991, 63, 1224, 2788, 16, 61, 2999, 199, 533, 24385, 8, 8933, 14, 16703, 304, 1128, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 1039, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 2999, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 1128, 986, 2999, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 1128, 986, 2999, 199, 5680, 14134, 859, 3261, 2999, 199, 318, 26116, 837, 1128, 372, 6010, 14, 26375, 8, 1039, 536, 534, 4595, 4830, 13, 24, 297, 1039, 3752, 29, 8818, 1252, 2143, 12, 1039, 4849, 29, 8818, 1252, 2708, 12, 1039, 26329, 29, 17016, 12, 1039, 26317, 29, 16703, 12, 1039, 26101, 29, 16132, 12, 1039, 26112, 29, 16551, 12, 1128, 776, 8065, 199, 5680, 27368, 6957, 2999, 199, 12796, 63, 1224, 275, 334, 1128, 399, 1154, 88, 383, 7, 258, 327, 221, 378, 88, 383, 1035, 5962, 1128, 399, 1154, 88, 614, 7, 258, 327, 221, 378, 88, 614, 1035, 13910, 1634, 32674, 1128, 399, 1154, 88, 996, 7, 258, 327, 221, 378, 88, 996, 1035, 13910, 1634, 11951, 1128, 399, 1154, 88, 1644, 7, 258, 327, 221, 378, 88, 1644, 1035, 7729, 1634, 11951, 1128, 399, 1154, 88, 966, 7, 258, 327, 221, 378, 88, 966, 1035, 7729, 1634, 22499, 1128, 399, 1154, 88, 1717, 7, 258, 327, 221, 378, 88, 1717, 1035, 5070, 31115, 57, 1128, 399, 1154, 88, 1690, 7, 258, 327, 221, 378, 88, 1690, 1035, 22549, 1128, 399, 1154, 88, 1780, 7, 258, 327, 221, 378, 88, 1780, 1035, 699, 14952, 1128, 399, 1154, 88, 2036, 7, 258, 327, 221, 378, 88, 2036, 1035, 22658, 11658, 1128, 399, 1154, 84, 7, 755, 327, 221, 378, 88, 1643, 1035, 8724, 22450, 1128, 399, 1154, 78, 7, 755, 327, 221, 378, 88, 16, 33, 1035, 13587, 21567, 1128, 399, 1154, 88, 16, 66, 7, 258, 327, 221, 378, 88, 16, 34, 1035, 8267, 22450, 1128, 399, 1154, 88, 16, 67, 7, 258, 327, 221, 378, 88, 16, 35, 1035, 11295, 21567, 1128, 399, 1154, 82, 7, 755, 327, 221, 378, 88, 16, 36, 1035, 445, 32622, 24646, 1128, 399, 1154, 88, 16, 69, 7, 258, 327, 221, 378, 88, 16, 37, 1035, 20754, 5738, 1128, 399, 1154, 88, 16, 70, 7, 258, 327, 221, 378, 88, 16, 38, 1035, 20754, 1621, 1128, 399, 1154, 88, 709, 7, 258, 327, 221, 378, 88, 709, 1035, 7126, 19774, 17682, 1128, 399, 1154, 88, 845, 7, 258, 327, 221, 378, 88, 845, 1035, 11643, 8098, 13051, 1128, 399, 1154, 88, 713, 7, 258, 327, 221, 378, 88, 713, 1035, 11643, 8098, 16562, 1128, 399, 1154, 88, 969, 7, 258, 327, 221, 378, 88, 969, 1035, 11643, 8098, 16296, 1128, 399, 1154, 88, 1079, 7, 258, 327, 221, 378, 88, 1079, 1035, 11643, 8098, 14473, 1128, 399, 1154, 88, 1046, 7, 258, 327, 221, 378, 88, 1046, 1035, 29837, 22549, 1128, 399, 1154, 88, 975, 7, 258, 327, 221, 378, 88, 975, 1035, 10046, 30782, 23240, 1128, 399, 1154, 88, 1196, 7, 258, 327, 221, 378, 88, 1196, 1035, 7729, 1634, 22499, 8068, 1128, 399, 1154, 88, 1085, 7, 258, 327, 221, 378, 88, 1085, 1035, 27385, 1128, 399, 1154, 88, 1167, 7, 258, 327, 221, 378, 88, 1167, 1035, 7729, 1634, 22650, 1128, 399, 1154, 88, 17, 65, 7, 258, 327, 221, 378, 88, 17, 33, 1035, 9103, 1128, 399, 1154, 88, 17, 66, 7, 258, 327, 221, 378, 88, 17, 34, 1035, 17682, 1128, 399, 1154, 88, 17, 67, 7, 258, 327, 221, 378, 88, 17, 35, 1035, 13024, 14782, 1128, 399, 1154, 88, 17, 68, 7, 258, 327, 221, 378, 88, 17, 36, 1035, 15443, 14782, 1128, 399, 1154, 88, 17, 69, 7, 258, 327, 221, 378, 88, 17, 37, 1035, 24973, 14782, 1128, 399, 1154, 88, 17, 70, 7, 258, 327, 221, 378, 88, 17, 38, 1035, 25836, 14782, 1128, 399, 7, 283, 263, 327, 221, 378, 88, 1165, 1035, 16796, 1128, 399, 7, 11213, 263, 327, 221, 378, 88, 2025, 1035, 24232, 8132, 1128, 399, 30385, 263, 327, 221, 378, 88, 1081, 1035, 11830, 8132, 1128, 399, 11525, 7, 263, 327, 221, 378, 88, 1789, 1035, 18122, 5056, 1128, 399, 7, 12913, 263, 327, 221, 378, 88, 1194, 1035, 30857, 5056, 1128, 399, 5956, 7, 263, 327, 221, 378, 88, 821, 1035, 26684, 5056, 1128, 399, 21840, 7, 263, 327, 221, 378, 88, 1479, 1035, 30602, 1128, 399, 2, 4065, 263, 327, 221, 378, 88, 1465, 1035, 30876, 1128, 399, 7, 360, 263, 327, 221, 378, 88, 1651, 1035, 6578, 20570, 1128, 399, 358, 7, 263, 327, 221, 378, 88, 1398, 1035, 7052, 20570, 1128, 399, 7, 10223, 263, 327, 221, 378, 88, 18, 33, 1035, 29725, 1128, 399, 30269, 263, 327, 221, 378, 88, 18, 34, 1035, 18807, 5056, 1128, 399, 1673, 263, 327, 221, 378, 88, 18, 35, 1035, 22849, 1128, 399, 12418, 7, 263, 327, 221, 378, 88, 18, 36, 1035, 22553, 13, 18004, 1128, 399, 30484, 263, 327, 221, 378, 88, 18, 37, 1035, 18530, 22348, 1128, 399, 29957, 263, 327, 221, 378, 88, 18, 38, 1035, 20585, 1128, 399, 7, 16, 7, 263, 327, 221, 378, 88, 1216, 1035, 7298, 20348, 1128, 399, 7, 17, 7, 263, 327, 221, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jart/tensorflow
tensorflow/contrib/keras/api/keras/applications/__init__.py
87
1807
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Keras Applications are canned architectures with pre-trained weights.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.keras.api.keras.applications import inception_v3 from tensorflow.contrib.keras.api.keras.applications import mobilenet from tensorflow.contrib.keras.api.keras.applications import resnet50 from tensorflow.contrib.keras.api.keras.applications import vgg16 from tensorflow.contrib.keras.api.keras.applications import vgg19 from tensorflow.contrib.keras.api.keras.applications import xception from tensorflow.contrib.keras.api.keras.applications.inception_v3 import InceptionV3 from tensorflow.contrib.keras.api.keras.applications.mobilenet import MobileNet from tensorflow.contrib.keras.api.keras.applications.resnet50 import ResNet50 from tensorflow.contrib.keras.api.keras.applications.vgg16 import VGG16 from tensorflow.contrib.keras.api.keras.applications.vgg19 import VGG19 from tensorflow.contrib.keras.api.keras.applications.xception import Xception del absolute_import del division del print_function
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 43, 30037, 24636, 787, 883, 7439, 3819, 1175, 22004, 543, 876, 13, 23782, 4931, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 315, 814, 63, 86, 19, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 21305, 846, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 522, 846, 1400, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 373, 2721, 975, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 373, 2721, 1167, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 671, 814, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 262, 814, 63, 86, 19, 492, 1010, 814, 54, 19, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 11375, 846, 492, 29724, 2480, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 28998, 1400, 492, 3591, 2480, 1400, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 27948, 975, 492, 812, 2916, 975, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 27948, 1167, 492, 812, 2916, 1167, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 16010, 492, 1323, 814, 199, 199, 2264, 3679, 63, 646, 199, 2264, 4629, 199, 2264, 870, 63, 1593, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 43, 30037, 24636, 787, 883, 7439, 3819, 1175, 22004, 543, 876, 13, 23782, 4931, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 315, 814, 63, 86, 19, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 21305, 846, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 522, 846, 1400, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 373, 2721, 975, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 373, 2721, 1167, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 492, 671, 814, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 262, 814, 63, 86, 19, 492, 1010, 814, 54, 19, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 11375, 846, 492, 29724, 2480, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 28998, 1400, 492, 3591, 2480, 1400, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 27948, 975, 492, 812, 2916, 975, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 27948, 1167, 492, 812, 2916, 1167, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1246, 14, 8811, 14, 15853, 14, 16010, 492, 1323, 814, 199, 199, 2264, 3679, 63, 646, 199, 2264, 4629, 199, 2264, 870, 63, 1593, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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0, 0, 0, 0, 0, 0, 0 ]
miyanishi2/caffe-rpc
caffe_extractor.py
1
1439
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'miyanishi' import caffe import numpy as np class CaffeExtractor(): def __init__(self, caffe_root=None, feature_layers=["fc6"], gpu=True): self.feature_layers = feature_layers MODEL_FILE = caffe_root + 'examples/imagenet/imagenet_deploy.prototxt' PRETRAINED = caffe_root + 'examples/imagenet/caffe_reference_imagenet_model' MEAN_FILE = caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy' self.net = caffe.Classifier(MODEL_FILE, PRETRAINED, mean=np.load(MEAN_FILE), channel_swap=(2,1,0), raw_scale=255, image_dims=(256, 256)) #self.net.set_phase_test() if gpu: self.net.set_mode_gpu() else: self.net.set_mode_cpu() imagenet_labels_filename = caffe_root + 'data/ilsvrc12/synset_words.txt' self.labels = np.loadtxt(imagenet_labels_filename, str, delimiter='\t') def getImageFeatures(self, image): score = self.net.predict([image]) feature_dic = {layer:np.copy(self.net.blobs[layer].data[4][:,0,0]) for layer in self.feature_layers} return feature_dic def getImageLabels(self): top_k = self.net.blobs['prob'].data[4].flatten().argsort()[-1:-6:-1] labels = self.labels[top_k].tolist() return labels
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 2502, 363, 275, 283, 2664, 89, 290, 2453, 73, 7, 199, 199, 646, 1704, 2026, 199, 646, 2680, 465, 980, 421, 199, 533, 8790, 2026, 11039, 837, 272, 347, 636, 826, 721, 277, 12, 1704, 2026, 63, 1231, 29, 403, 12, 3878, 63, 4359, 6270, 3003, 22, 2255, 21758, 29, 549, 304, 267, 291, 14, 4445, 63, 4359, 275, 3878, 63, 4359, 267, 10362, 4424, 63, 3817, 275, 1704, 2026, 63, 1231, 435, 283, 8589, 15, 11744, 2268, 386, 15, 11744, 2268, 386, 63, 11060, 14, 2745, 357, 400, 7, 267, 510, 7341, 21715, 1149, 275, 1704, 2026, 63, 1231, 435, 283, 8589, 15, 11744, 2268, 386, 15, 18260, 63, 4443, 63, 11744, 2268, 386, 63, 1238, 7, 267, 603, 37, 879, 63, 3817, 275, 1704, 2026, 63, 1231, 435, 283, 1548, 15, 18260, 15, 11744, 2268, 386, 15, 382, 2772, 1195, 63, 7409, 63, 3670, 14, 20245, 7, 267, 291, 14, 846, 275, 1704, 2026, 14, 8508, 8, 11429, 63, 3817, 12, 510, 7341, 21715, 1149, 12, 4615, 29, 1590, 14, 912, 8, 31840, 63, 3817, 395, 2511, 3623, 63, 9286, 2687, 18, 12, 17, 12, 16, 395, 2511, 3066, 63, 3467, 29, 2299, 12, 2511, 1834, 63, 5380, 2687, 3912, 12, 7633, 430, 267, 327, 277, 14, 846, 14, 409, 63, 6971, 63, 396, 342, 267, 340, 21758, 26, 288, 291, 14, 846, 14, 409, 63, 632, 63, 6477, 342, 267, 587, 26, 288, 291, 14, 846, 14, 409, 63, 632, 63, 3541, 342, 267, 18884, 2268, 386, 63, 3512, 63, 1501, 275, 1704, 2026, 63, 1231, 435, 283, 576, 15, 382, 2772, 1195, 713, 15, 9466, 409, 63, 3148, 14, 2424, 7, 267, 291, 14, 3512, 275, 980, 14, 27992, 8, 11744, 2268, 386, 63, 3512, 63, 1501, 12, 620, 12, 11172, 17115, 84, 358, 2378, 347, 664, 3491, 10807, 8, 277, 12, 1834, 304, 267, 5396, 275, 291, 14, 846, 14, 6892, 779, 1569, 566, 267, 3878, 63, 5000, 275, 469, 1897, 26, 1590, 14, 1574, 8, 277, 14, 846, 14, 21893, 59, 1897, 1055, 576, 59, 20, 61, 3981, 16, 12, 16, 566, 367, 4045, 315, 291, 14, 4445, 63, 4359, 93, 267, 372, 3878, 63, 5000, 339, 347, 664, 3491, 14016, 8, 277, 304, 267, 2746, 63, 75, 275, 291, 14, 846, 14, 21893, 459, 6101, 2278, 576, 59, 20, 1055, 8487, 1252, 20188, 19105, 17, 6809, 22, 6809, 17, 61, 267, 3628, 275, 291, 14, 3512, 59, 2119, 63, 75, 1055, 13633, 342, 267, 372, 3628, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 2502, 363, 275, 283, 2664, 89, 290, 2453, 73, 7, 199, 199, 646, 1704, 2026, 199, 646, 2680, 465, 980, 421, 199, 533, 8790, 2026, 11039, 837, 272, 347, 636, 826, 721, 277, 12, 1704, 2026, 63, 1231, 29, 403, 12, 3878, 63, 4359, 6270, 3003, 22, 2255, 21758, 29, 549, 304, 267, 291, 14, 4445, 63, 4359, 275, 3878, 63, 4359, 267, 10362, 4424, 63, 3817, 275, 1704, 2026, 63, 1231, 435, 283, 8589, 15, 11744, 2268, 386, 15, 11744, 2268, 386, 63, 11060, 14, 2745, 357, 400, 7, 267, 510, 7341, 21715, 1149, 275, 1704, 2026, 63, 1231, 435, 283, 8589, 15, 11744, 2268, 386, 15, 18260, 63, 4443, 63, 11744, 2268, 386, 63, 1238, 7, 267, 603, 37, 879, 63, 3817, 275, 1704, 2026, 63, 1231, 435, 283, 1548, 15, 18260, 15, 11744, 2268, 386, 15, 382, 2772, 1195, 63, 7409, 63, 3670, 14, 20245, 7, 267, 291, 14, 846, 275, 1704, 2026, 14, 8508, 8, 11429, 63, 3817, 12, 510, 7341, 21715, 1149, 12, 4615, 29, 1590, 14, 912, 8, 31840, 63, 3817, 395, 2511, 3623, 63, 9286, 2687, 18, 12, 17, 12, 16, 395, 2511, 3066, 63, 3467, 29, 2299, 12, 2511, 1834, 63, 5380, 2687, 3912, 12, 7633, 430, 267, 327, 277, 14, 846, 14, 409, 63, 6971, 63, 396, 342, 267, 340, 21758, 26, 288, 291, 14, 846, 14, 409, 63, 632, 63, 6477, 342, 267, 587, 26, 288, 291, 14, 846, 14, 409, 63, 632, 63, 3541, 342, 267, 18884, 2268, 386, 63, 3512, 63, 1501, 275, 1704, 2026, 63, 1231, 435, 283, 576, 15, 382, 2772, 1195, 713, 15, 9466, 409, 63, 3148, 14, 2424, 7, 267, 291, 14, 3512, 275, 980, 14, 27992, 8, 11744, 2268, 386, 63, 3512, 63, 1501, 12, 620, 12, 11172, 17115, 84, 358, 2378, 347, 664, 3491, 10807, 8, 277, 12, 1834, 304, 267, 5396, 275, 291, 14, 846, 14, 6892, 779, 1569, 566, 267, 3878, 63, 5000, 275, 469, 1897, 26, 1590, 14, 1574, 8, 277, 14, 846, 14, 21893, 59, 1897, 1055, 576, 59, 20, 61, 3981, 16, 12, 16, 566, 367, 4045, 315, 291, 14, 4445, 63, 4359, 93, 267, 372, 3878, 63, 5000, 339, 347, 664, 3491, 14016, 8, 277, 304, 267, 2746, 63, 75, 275, 291, 14, 846, 14, 21893, 459, 6101, 2278, 576, 59, 20, 1055, 8487, 1252, 20188, 19105, 17, 6809, 22, 6809, 17, 61, 267, 3628, 275, 291, 14, 3512, 59, 2119, 63, 75, 1055, 13633, 342, 267, 372, 3628, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Donkyhotay/MoonPy
twisted/internet/posixbase.py
1
14121
# -*- test-case-name: twisted.test.test_internet -*- # Copyright (c) 2001-2009 Twisted Matrix Laboratories. # See LICENSE for details. """ Posix reactor base class """ import warnings import socket import errno import os from zope.interface import implements, classImplements from twisted.python.compat import set from twisted.internet.interfaces import IReactorUNIX, IReactorUNIXDatagram from twisted.internet.interfaces import IReactorTCP, IReactorUDP, IReactorSSL, IReactorArbitrary from twisted.internet.interfaces import IReactorProcess, IReactorMulticast from twisted.internet.interfaces import IHalfCloseableDescriptor from twisted.internet import error from twisted.internet import tcp, udp from twisted.python import log, failure, util from twisted.persisted import styles from twisted.python.runtime import platformType, platform from twisted.internet.base import ReactorBase, _SignalReactorMixin try: from twisted.internet import ssl sslEnabled = True except ImportError: sslEnabled = False try: from twisted.internet import unix unixEnabled = True except ImportError: unixEnabled = False processEnabled = False if platformType == 'posix': from twisted.internet import fdesc import process processEnabled = True if platform.isWindows(): try: import win32process processEnabled = True except ImportError: win32process = None class _Win32Waker(log.Logger, styles.Ephemeral): """I am a workaround for the lack of pipes on win32. I am a pair of connected sockets which can wake up the main loop from another thread. """ disconnected = 0 def __init__(self, reactor): """Initialize. """ self.reactor = reactor # Following select_trigger (from asyncore)'s example; server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.setsockopt(socket.IPPROTO_TCP, 1, 1) server.bind(('127.0.0.1', 0)) server.listen(1) client.connect(server.getsockname()) reader, clientaddr = server.accept() client.setblocking(0) reader.setblocking(0) self.r = reader self.w = client self.fileno = self.r.fileno def wakeUp(self): """Send a byte to my connection. """ try: util.untilConcludes(self.w.send, 'x') except socket.error, (err, msg): if err != errno.WSAEWOULDBLOCK: raise def doRead(self): """Read some data from my connection. """ try: self.r.recv(8192) except socket.error: pass def connectionLost(self, reason): self.r.close() self.w.close() class _UnixWaker(log.Logger, styles.Ephemeral): """This class provides a simple interface to wake up the event loop. This is used by threads or signals to wake up the event loop. """ disconnected = 0 i = None o = None def __init__(self, reactor): """Initialize. """ self.reactor = reactor self.i, self.o = os.pipe() fdesc.setNonBlocking(self.i) fdesc._setCloseOnExec(self.i) fdesc.setNonBlocking(self.o) fdesc._setCloseOnExec(self.o) self.fileno = lambda: self.i def doRead(self): """Read some bytes from the pipe. """ fdesc.readFromFD(self.fileno(), lambda data: None) def wakeUp(self): """Write one byte to the pipe, and flush it. """ # We don't use fdesc.writeToFD since we need to distinguish # between EINTR (try again) and EAGAIN (do nothing). if self.o is not None: try: util.untilConcludes(os.write, self.o, 'x') except OSError, e: if e.errno != errno.EAGAIN: raise def connectionLost(self, reason): """Close both ends of my pipe. """ if not hasattr(self, "o"): return for fd in self.i, self.o: try: os.close(fd) except IOError: pass del self.i, self.o if platformType == 'posix': _Waker = _UnixWaker elif platformType == 'win32': _Waker = _Win32Waker class PosixReactorBase(_SignalReactorMixin, ReactorBase): """ A basis for reactors that use file descriptors. """ implements(IReactorArbitrary, IReactorTCP, IReactorUDP, IReactorMulticast) def __init__(self): ReactorBase.__init__(self) if self.usingThreads or platformType == "posix": self.installWaker() def _disconnectSelectable(self, selectable, why, isRead, faildict={ error.ConnectionDone: failure.Failure(error.ConnectionDone()), error.ConnectionLost: failure.Failure(error.ConnectionLost()) }): """ Utility function for disconnecting a selectable. Supports half-close notification, isRead should be boolean indicating whether error resulted from doRead(). """ self.removeReader(selectable) f = faildict.get(why.__class__) if f: if (isRead and why.__class__ == error.ConnectionDone and IHalfCloseableDescriptor.providedBy(selectable)): selectable.readConnectionLost(f) else: self.removeWriter(selectable) selectable.connectionLost(f) else: self.removeWriter(selectable) selectable.connectionLost(failure.Failure(why)) def installWaker(self): """ Install a `waker' to allow threads and signals to wake up the IO thread. We use the self-pipe trick (http://cr.yp.to/docs/selfpipe.html) to wake the reactor. On Windows we use a pair of sockets. """ if not self.waker: self.waker = _Waker(self) self._internalReaders.add(self.waker) self.addReader(self.waker) # IReactorProcess def spawnProcess(self, processProtocol, executable, args=(), env={}, path=None, uid=None, gid=None, usePTY=0, childFDs=None): args, env = self._checkProcessArgs(args, env) if platformType == 'posix': if usePTY: if childFDs is not None: raise ValueError("Using childFDs is not supported with usePTY=True.") return process.PTYProcess(self, executable, args, env, path, processProtocol, uid, gid, usePTY) else: return process.Process(self, executable, args, env, path, processProtocol, uid, gid, childFDs) elif platformType == "win32": if uid is not None or gid is not None: raise ValueError("The uid and gid parameters are not supported on Windows.") if usePTY: raise ValueError("The usePTY parameter is not supported on Windows.") if childFDs: raise ValueError("Customizing childFDs is not supported on Windows.") if win32process: from twisted.internet._dumbwin32proc import Process return Process(self, processProtocol, executable, args, env, path) else: raise NotImplementedError, "spawnProcess not available since pywin32 is not installed." else: raise NotImplementedError, "spawnProcess only available on Windows or POSIX." # IReactorUDP def listenUDP(self, port, protocol, interface='', maxPacketSize=8192): """Connects a given L{DatagramProtocol} to the given numeric UDP port. @returns: object conforming to L{IListeningPort}. """ p = udp.Port(port, protocol, interface, maxPacketSize, self) p.startListening() return p def connectUDP(self, remotehost, remoteport, protocol, localport=0, interface='', maxPacketSize=8192): """DEPRECATED. Connects a L{ConnectedDatagramProtocol} instance to a UDP port. """ warnings.warn("use listenUDP and then transport.connect().", DeprecationWarning, stacklevel=2) p = udp.ConnectedPort((remotehost, remoteport), localport, protocol, interface, maxPacketSize, self) p.startListening() return p # IReactorMulticast def listenMulticast(self, port, protocol, interface='', maxPacketSize=8192, listenMultiple=False): """Connects a given DatagramProtocol to the given numeric UDP port. EXPERIMENTAL. @returns: object conforming to IListeningPort. """ p = udp.MulticastPort(port, protocol, interface, maxPacketSize, self, listenMultiple) p.startListening() return p # IReactorUNIX def connectUNIX(self, address, factory, timeout=30, checkPID=0): """@see: twisted.internet.interfaces.IReactorUNIX.connectUNIX """ assert unixEnabled, "UNIX support is not present" c = unix.Connector(address, factory, timeout, self, checkPID) c.connect() return c _unspecified = object() def _checkMode(self, name, mode): """ Check C{mode} to see if a value was specified for it and emit a deprecation warning if so. Return the default value if none was specified, otherwise return C{mode}. """ if mode is not self._unspecified: warnings.warn( 'The mode parameter of %(name)s will be removed. Do not pass ' 'a value for it. Set permissions on the containing directory ' 'before calling %(name)s, instead.' % dict(name=name), category=DeprecationWarning, stacklevel=3) else: mode = 0666 return mode def listenUNIX(self, address, factory, backlog=50, mode=_unspecified, wantPID=0): """ @see: twisted.internet.interfaces.IReactorUNIX.listenUNIX """ assert unixEnabled, "UNIX support is not present" mode = self._checkMode('IReactorUNIX.listenUNIX', mode) p = unix.Port(address, factory, backlog, mode, self, wantPID) p.startListening() return p # IReactorUNIXDatagram def listenUNIXDatagram(self, address, protocol, maxPacketSize=8192, mode=_unspecified): """ Connects a given L{DatagramProtocol} to the given path. EXPERIMENTAL. @returns: object conforming to L{IListeningPort}. """ assert unixEnabled, "UNIX support is not present" mode = self._checkMode('IReactorUNIXDatagram.listenUNIXDatagram', mode) p = unix.DatagramPort(address, protocol, maxPacketSize, mode, self) p.startListening() return p def connectUNIXDatagram(self, address, protocol, maxPacketSize=8192, mode=_unspecified, bindAddress=None): """ Connects a L{ConnectedDatagramProtocol} instance to a path. EXPERIMENTAL. """ assert unixEnabled, "UNIX support is not present" mopde = self._checkMode('IReactorUNIXDatagram.connectUNIXDatagram', mode) p = unix.ConnectedDatagramPort(address, protocol, maxPacketSize, mode, bindAddress, self) p.startListening() return p # IReactorTCP def listenTCP(self, port, factory, backlog=50, interface=''): """@see: twisted.internet.interfaces.IReactorTCP.listenTCP """ p = tcp.Port(port, factory, backlog, interface, self) p.startListening() return p def connectTCP(self, host, port, factory, timeout=30, bindAddress=None): """@see: twisted.internet.interfaces.IReactorTCP.connectTCP """ c = tcp.Connector(host, port, factory, timeout, bindAddress, self) c.connect() return c # IReactorSSL (sometimes, not implemented) def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None): """@see: twisted.internet.interfaces.IReactorSSL.connectSSL """ assert sslEnabled, "SSL support is not present" c = ssl.Connector(host, port, factory, contextFactory, timeout, bindAddress, self) c.connect() return c def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''): """@see: twisted.internet.interfaces.IReactorSSL.listenSSL """ assert sslEnabled, "SSL support is not present" p = ssl.Port(port, factory, contextFactory, backlog, interface, self) p.startListening() return p # IReactorArbitrary def listenWith(self, portType, *args, **kw): kw['reactor'] = self p = portType(*args, **kw) p.startListening() return p def connectWith(self, connectorType, *args, **kw): kw['reactor'] = self c = connectorType(*args, **kw) c.connect() return c def _removeAll(self, readers, writers): """ Remove all readers and writers, and list of removed L{IReadDescriptor}s and L{IWriteDescriptor}s. Meant for calling from subclasses, to implement removeAll, like:: def removeAll(self): return self._removeAll(self._reads, self._writes) where C{self._reads} and C{self._writes} are iterables. """ removedReaders = set(readers) - self._internalReaders for reader in removedReaders: self.removeReader(reader) removedWriters = set(writers) for writer in removedWriters: self.removeWriter(writer) return list(removedReaders | removedWriters) if sslEnabled: classImplements(PosixReactorBase, IReactorSSL) if unixEnabled: classImplements(PosixReactorBase, IReactorUNIX, IReactorUNIXDatagram) if processEnabled: classImplements(PosixReactorBase, IReactorProcess) __all__ = ["PosixReactorBase"]
gpl-3.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 4901, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 1575, 4174, 9655, 1300, 1021, 199, 624, 199, 199, 646, 3598, 199, 646, 2838, 199, 646, 7554, 199, 646, 747, 199, 199, 504, 20110, 14, 3266, 492, 9031, 12, 1021, 29452, 199, 199, 504, 7390, 14, 1548, 14, 5819, 492, 663, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 19584, 12, 473, 15860, 19584, 1451, 1679, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 9735, 12, 473, 15860, 17457, 12, 473, 15860, 5413, 12, 473, 15860, 1596, 8734, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 3498, 12, 473, 15860, 8550, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 21132, 4724, 461, 4311, 199, 504, 7390, 14, 4901, 492, 1125, 199, 504, 7390, 14, 4901, 492, 14719, 12, 18419, 199, 199, 504, 7390, 14, 1548, 492, 943, 12, 5988, 12, 4884, 199, 504, 7390, 14, 529, 24925, 492, 15725, 199, 504, 7390, 14, 1548, 14, 7726, 492, 4298, 804, 12, 4298, 199, 199, 504, 7390, 14, 4901, 14, 1095, 492, 799, 5021, 1563, 12, 485, 11274, 15860, 4256, 199, 199, 893, 26, 272, 687, 7390, 14, 4901, 492, 6149, 272, 6149, 6589, 275, 715, 199, 2590, 3545, 26, 272, 6149, 6589, 275, 756, 199, 199, 893, 26, 272, 687, 7390, 14, 4901, 492, 16572, 272, 16572, 6589, 275, 715, 199, 2590, 3545, 26, 272, 16572, 6589, 275, 756, 199, 199, 1412, 6589, 275, 756, 199, 692, 4298, 804, 508, 283, 9228, 356, 272, 687, 7390, 14, 4901, 492, 289, 3257, 272, 492, 2112, 272, 2112, 6589, 275, 715, 199, 199, 692, 4298, 14, 374, 8647, 837, 272, 862, 26, 267, 492, 4747, 708, 1412, 267, 2112, 6589, 275, 715, 272, 871, 3545, 26, 267, 4747, 708, 1412, 275, 488, 421, 199, 533, 485, 8886, 708, 55, 12630, 8, 793, 14, 4455, 12, 15725, 14, 14057, 14572, 304, 272, 408, 41, 8140, 282, 18092, 367, 314, 29098, 402, 20988, 641, 4747, 708, 14, 339, 473, 8140, 282, 4092, 402, 8539, 18772, 1314, 883, 21560, 1536, 314, 2446, 4438, 272, 687, 4573, 2462, 14, 272, 408, 272, 25602, 275, 378, 339, 347, 636, 826, 721, 277, 12, 9655, 304, 267, 408, 9345, 14, 267, 408, 267, 291, 14, 13544, 275, 9655, 267, 327, 21876, 316, 3504, 63, 7631, 334, 504, 30328, 3171, 83, 2893, 27, 267, 1654, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 267, 1890, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 267, 1890, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 413, 12, 413, 9, 267, 1654, 14, 3409, 4725, 4195, 14, 16, 14, 16, 14, 17, 297, 378, 430, 267, 1654, 14, 5859, 8, 17, 9, 267, 1890, 14, 2242, 8, 1000, 14, 27886, 1012, 267, 7002, 12, 1890, 2697, 275, 1654, 14, 5694, 342, 267, 1890, 14, 409, 13091, 8, 16, 9, 267, 7002, 14, 409, 13091, 8, 16, 9, 267, 291, 14, 82, 275, 7002, 267, 291, 14, 87, 275, 1890, 267, 291, 14, 9843, 275, 291, 14, 82, 14, 9843, 339, 347, 21560, 1721, 8, 277, 304, 267, 408, 6795, 282, 3696, 370, 3002, 1950, 14, 267, 408, 267, 862, 26, 288, 4884, 14, 8111, 714, 1285, 83, 8, 277, 14, 87, 14, 2254, 12, 283, 88, 358, 267, 871, 2838, 14, 705, 12, 334, 1508, 12, 1499, 304, 288, 340, 2329, 1137, 7554, 14, 55, 4251, 37, 11325, 1293, 2846, 4406, 26, 355, 746, 339, 347, 886, 3284, 8, 277, 304, 267, 408, 3284, 2005, 666, 687, 3002, 1950, 14, 267, 408, 267, 862, 26, 288, 291, 14, 82, 14, 7637, 8, 31526, 9, 267, 871, 2838, 14, 705, 26, 288, 986, 339, 347, 1950, 14074, 8, 277, 12, 4499, 304, 267, 291, 14, 82, 14, 1600, 342, 267, 291, 14, 87, 14, 1600, 342, 421, 199, 533, 485, 21607, 55, 12630, 8, 793, 14, 4455, 12, 15725, 14, 14057, 14572, 304, 272, 408, 2765, 1021, 6571, 282, 3486, 3217, 370, 21560, 1536, 314, 1566, 4438, 14, 339, 961, 365, 1202, 701, 7183, 503, 10166, 370, 21560, 1536, 314, 1566, 4438, 14, 272, 408, 272, 25602, 275, 378, 339, 284, 275, 488, 272, 312, 275, 488, 339, 347, 636, 826, 721, 277, 12, 9655, 304, 267, 408, 9345, 14, 267, 408, 267, 291, 14, 13544, 275, 9655, 267, 291, 14, 73, 12, 291, 14, 79, 275, 747, 14, 4990, 342, 267, 289, 3257, 14, 409, 6932, 27132, 8, 277, 14, 73, 9, 267, 289, 3257, 423, 409, 4724, 3314, 4858, 8, 277, 14, 73, 9, 267, 289, 3257, 14, 409, 6932, 27132, 8, 277, 14, 79, 9, 267, 289, 3257, 423, 409, 4724, 3314, 4858, 8, 277, 14, 79, 9, 267, 291, 14, 9843, 275, 2400, 26, 291, 14, 73, 339, 347, 886, 3284, 8, 277, 304, 267, 408, 3284, 2005, 2783, 687, 314, 5200, 14, 267, 408, 267, 289, 3257, 14, 739, 2532, 7902, 8, 277, 14, 9843, 1062, 2400, 666, 26, 488, 9, 339, 347, 21560, 1721, 8, 277, 304, 267, 408, 3534, 1373, 3696, 370, 314, 5200, 12, 436, 8976, 652, 14, 267, 408, 267, 327, 2136, 2793, 1133, 675, 289, 3257, 14, 952, 1378, 7902, 3967, 781, 1929, 370, 22237, 267, 327, 3382, 662, 19652, 334, 893, 4020, 9, 436, 662, 1254, 9021, 334, 1117, 6548, 680, 267, 340, 291, 14, 79, 365, 440, 488, 26, 288, 862, 26, 355, 4884, 14, 8111, 714, 1285, 83, 8, 736, 14, 952, 12, 291, 14, 79, 12, 283, 88, 358, 288, 871, 6440, 12, 325, 26, 355, 340, 325, 14, 7931, 1137, 7554, 14, 37, 1254, 9021, 26, 490, 746, 339, 347, 1950, 14074, 8, 277, 12, 4499, 304, 267, 408, 4724, 3865, 11187, 402, 3002, 5200, 14, 267, 408, 267, 340, 440, 2688, 8, 277, 12, 298, 79, 2349, 288, 372, 267, 367, 6111, 315, 291, 14, 73, 12, 291, 14, 79, 26, 288, 862, 26, 355, 747 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 4901, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 1575, 4174, 9655, 1300, 1021, 199, 624, 199, 199, 646, 3598, 199, 646, 2838, 199, 646, 7554, 199, 646, 747, 199, 199, 504, 20110, 14, 3266, 492, 9031, 12, 1021, 29452, 199, 199, 504, 7390, 14, 1548, 14, 5819, 492, 663, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 19584, 12, 473, 15860, 19584, 1451, 1679, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 9735, 12, 473, 15860, 17457, 12, 473, 15860, 5413, 12, 473, 15860, 1596, 8734, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 15860, 3498, 12, 473, 15860, 8550, 199, 504, 7390, 14, 4901, 14, 7436, 492, 473, 21132, 4724, 461, 4311, 199, 504, 7390, 14, 4901, 492, 1125, 199, 504, 7390, 14, 4901, 492, 14719, 12, 18419, 199, 199, 504, 7390, 14, 1548, 492, 943, 12, 5988, 12, 4884, 199, 504, 7390, 14, 529, 24925, 492, 15725, 199, 504, 7390, 14, 1548, 14, 7726, 492, 4298, 804, 12, 4298, 199, 199, 504, 7390, 14, 4901, 14, 1095, 492, 799, 5021, 1563, 12, 485, 11274, 15860, 4256, 199, 199, 893, 26, 272, 687, 7390, 14, 4901, 492, 6149, 272, 6149, 6589, 275, 715, 199, 2590, 3545, 26, 272, 6149, 6589, 275, 756, 199, 199, 893, 26, 272, 687, 7390, 14, 4901, 492, 16572, 272, 16572, 6589, 275, 715, 199, 2590, 3545, 26, 272, 16572, 6589, 275, 756, 199, 199, 1412, 6589, 275, 756, 199, 692, 4298, 804, 508, 283, 9228, 356, 272, 687, 7390, 14, 4901, 492, 289, 3257, 272, 492, 2112, 272, 2112, 6589, 275, 715, 199, 199, 692, 4298, 14, 374, 8647, 837, 272, 862, 26, 267, 492, 4747, 708, 1412, 267, 2112, 6589, 275, 715, 272, 871, 3545, 26, 267, 4747, 708, 1412, 275, 488, 421, 199, 533, 485, 8886, 708, 55, 12630, 8, 793, 14, 4455, 12, 15725, 14, 14057, 14572, 304, 272, 408, 41, 8140, 282, 18092, 367, 314, 29098, 402, 20988, 641, 4747, 708, 14, 339, 473, 8140, 282, 4092, 402, 8539, 18772, 1314, 883, 21560, 1536, 314, 2446, 4438, 272, 687, 4573, 2462, 14, 272, 408, 272, 25602, 275, 378, 339, 347, 636, 826, 721, 277, 12, 9655, 304, 267, 408, 9345, 14, 267, 408, 267, 291, 14, 13544, 275, 9655, 267, 327, 21876, 316, 3504, 63, 7631, 334, 504, 30328, 3171, 83, 2893, 27, 267, 1654, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 267, 1890, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 267, 1890, 14, 27689, 8, 3450, 14, 20130, 63, 9735, 12, 413, 12, 413, 9, 267, 1654, 14, 3409, 4725, 4195, 14, 16, 14, 16, 14, 17, 297, 378, 430, 267, 1654, 14, 5859, 8, 17, 9, 267, 1890, 14, 2242, 8, 1000, 14, 27886, 1012, 267, 7002, 12, 1890, 2697, 275, 1654, 14, 5694, 342, 267, 1890, 14, 409, 13091, 8, 16, 9, 267, 7002, 14, 409, 13091, 8, 16, 9, 267, 291, 14, 82, 275, 7002, 267, 291, 14, 87, 275, 1890, 267, 291, 14, 9843, 275, 291, 14, 82, 14, 9843, 339, 347, 21560, 1721, 8, 277, 304, 267, 408, 6795, 282, 3696, 370, 3002, 1950, 14, 267, 408, 267, 862, 26, 288, 4884, 14, 8111, 714, 1285, 83, 8, 277, 14, 87, 14, 2254, 12, 283, 88, 358, 267, 871, 2838, 14, 705, 12, 334, 1508, 12, 1499, 304, 288, 340, 2329, 1137, 7554, 14, 55, 4251, 37, 11325, 1293, 2846, 4406, 26, 355, 746, 339, 347, 886, 3284, 8, 277, 304, 267, 408, 3284, 2005, 666, 687, 3002, 1950, 14, 267, 408, 267, 862, 26, 288, 291, 14, 82, 14, 7637, 8, 31526, 9, 267, 871, 2838, 14, 705, 26, 288, 986, 339, 347, 1950, 14074, 8, 277, 12, 4499, 304, 267, 291, 14, 82, 14, 1600, 342, 267, 291, 14, 87, 14, 1600, 342, 421, 199, 533, 485, 21607, 55, 12630, 8, 793, 14, 4455, 12, 15725, 14, 14057, 14572, 304, 272, 408, 2765, 1021, 6571, 282, 3486, 3217, 370, 21560, 1536, 314, 1566, 4438, 14, 339, 961, 365, 1202, 701, 7183, 503, 10166, 370, 21560, 1536, 314, 1566, 4438, 14, 272, 408, 272, 25602, 275, 378, 339, 284, 275, 488, 272, 312, 275, 488, 339, 347, 636, 826, 721, 277, 12, 9655, 304, 267, 408, 9345, 14, 267, 408, 267, 291, 14, 13544, 275, 9655, 267, 291, 14, 73, 12, 291, 14, 79, 275, 747, 14, 4990, 342, 267, 289, 3257, 14, 409, 6932, 27132, 8, 277, 14, 73, 9, 267, 289, 3257, 423, 409, 4724, 3314, 4858, 8, 277, 14, 73, 9, 267, 289, 3257, 14, 409, 6932, 27132, 8, 277, 14, 79, 9, 267, 289, 3257, 423, 409, 4724, 3314, 4858, 8, 277, 14, 79, 9, 267, 291, 14, 9843, 275, 2400, 26, 291, 14, 73, 339, 347, 886, 3284, 8, 277, 304, 267, 408, 3284, 2005, 2783, 687, 314, 5200, 14, 267, 408, 267, 289, 3257, 14, 739, 2532, 7902, 8, 277, 14, 9843, 1062, 2400, 666, 26, 488, 9, 339, 347, 21560, 1721, 8, 277, 304, 267, 408, 3534, 1373, 3696, 370, 314, 5200, 12, 436, 8976, 652, 14, 267, 408, 267, 327, 2136, 2793, 1133, 675, 289, 3257, 14, 952, 1378, 7902, 3967, 781, 1929, 370, 22237, 267, 327, 3382, 662, 19652, 334, 893, 4020, 9, 436, 662, 1254, 9021, 334, 1117, 6548, 680, 267, 340, 291, 14, 79, 365, 440, 488, 26, 288, 862, 26, 355, 4884, 14, 8111, 714, 1285, 83, 8, 736, 14, 952, 12, 291, 14, 79, 12, 283, 88, 358, 288, 871, 6440, 12, 325, 26, 355, 340, 325, 14, 7931, 1137, 7554, 14, 37, 1254, 9021, 26, 490, 746, 339, 347, 1950, 14074, 8, 277, 12, 4499, 304, 267, 408, 4724, 3865, 11187, 402, 3002, 5200, 14, 267, 408, 267, 340, 440, 2688, 8, 277, 12, 298, 79, 2349, 288, 372, 267, 367, 6111, 315, 291, 14, 73, 12, 291, 14, 79, 26, 288, 862, 26, 355, 747, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
unfoldingWord-dev/uwadmin
uwadmin/migrations/0005_auto_20150524_1534.py
1
1202
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('uwadmin', '0004_auto_20150318_0034'), ] operations = [ migrations.AddField( model_name='publishrequest', name='approved_at', field=models.DateTimeField(default=None, null=True, db_index=True, blank=True), preserve_default=True, ), migrations.AddField( model_name='publishrequest', name='source_text', field=models.ForeignKey(related_name='source_publish_requests', to='uwadmin.LangCode', null=True), preserve_default=True, ), migrations.AddField( model_name='publishrequest', name='source_version', field=models.CharField(max_length=10, blank=True), preserve_default=True, ), migrations.AlterField( model_name='publishrequest', name='language', field=models.ForeignKey(related_name='publish_requests', to='uwadmin.LangCode'), preserve_default=True, ), ]
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 29638, 2113, 297, 283, 16643, 63, 2495, 63, 1797, 15773, 1085, 63, 383, 1082, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 21556, 63, 292, 297, 288, 901, 29, 992, 14, 4626, 8, 885, 29, 403, 12, 2973, 29, 549, 12, 1592, 63, 1080, 29, 549, 12, 4596, 29, 549, 395, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 1365, 63, 505, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 1365, 63, 4763, 63, 6615, 297, 370, 534, 29638, 2113, 14, 14654, 3034, 297, 2973, 29, 549, 395, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 1365, 63, 1023, 297, 288, 901, 29, 992, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 4596, 29, 549, 395, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 3671, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 4763, 63, 6615, 297, 370, 534, 29638, 2113, 14, 14654, 3034, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 29638, 2113, 297, 283, 16643, 63, 2495, 63, 1797, 15773, 1085, 63, 383, 1082, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 21556, 63, 292, 297, 288, 901, 29, 992, 14, 4626, 8, 885, 29, 403, 12, 2973, 29, 549, 12, 1592, 63, 1080, 29, 549, 12, 4596, 29, 549, 395, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 1365, 63, 505, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 1365, 63, 4763, 63, 6615, 297, 370, 534, 29638, 2113, 14, 14654, 3034, 297, 2973, 29, 549, 395, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 1365, 63, 1023, 297, 288, 901, 29, 992, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 4596, 29, 549, 395, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 4763, 1069, 297, 288, 536, 534, 3671, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 4763, 63, 6615, 297, 370, 534, 29638, 2113, 14, 14654, 3034, 659, 288, 11211, 63, 885, 29, 549, 12, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
leezu/mxnet
python/mxnet/gluon/__init__.py
7
1132
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # coding: utf-8 # pylint: disable=wildcard-import """Neural network module.""" from . import metric from .parameter import * from .block import * from . import nn from . import rnn from .trainer import * from . import loss from . import utils from . import data from . import model_zoo from . import contrib from . import probability
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 2803, 26, 2774, 13, 24, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 199, 624, 4698, 4889, 2784, 859, 1041, 199, 199, 504, 1275, 492, 6370, 199, 199, 504, 1275, 5329, 492, 627, 199, 199, 504, 1275, 1457, 492, 627, 199, 199, 504, 1275, 492, 11542, 199, 199, 504, 1275, 492, 19433, 199, 199, 504, 1275, 2834, 281, 492, 627, 199, 199, 504, 1275, 492, 5621, 199, 199, 504, 1275, 492, 3778, 199, 199, 504, 1275, 492, 666, 199, 199, 504, 1275, 492, 1402, 63, 90, 1534, 199, 199, 504, 1275, 492, 5914, 199, 199, 504, 1275, 492, 12224, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 3, 2803, 26, 2774, 13, 24, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 199, 624, 4698, 4889, 2784, 859, 1041, 199, 199, 504, 1275, 492, 6370, 199, 199, 504, 1275, 5329, 492, 627, 199, 199, 504, 1275, 1457, 492, 627, 199, 199, 504, 1275, 492, 11542, 199, 199, 504, 1275, 492, 19433, 199, 199, 504, 1275, 2834, 281, 492, 627, 199, 199, 504, 1275, 492, 5621, 199, 199, 504, 1275, 492, 3778, 199, 199, 504, 1275, 492, 666, 199, 199, 504, 1275, 492, 1402, 63, 90, 1534, 199, 199, 504, 1275, 492, 5914, 199, 199, 504, 1275, 492, 12224, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cpcloud/bokeh
examples/glyphs/dateaxis.py
2
1590
from __future__ import print_function from numpy import pi, arange, sin import numpy as np import time from bokeh.browserlib import view from bokeh.document import Document from bokeh.embed import file_html from bokeh.glyphs import Circle from bokeh.objects import (Plot, DataRange1d, LinearAxis, DatetimeAxis, ColumnDataSource, Glyph, PanTool, WheelZoomTool) from bokeh.resources import INLINE x = arange(-2 * pi, 2 * pi, 0.1) y = sin(x) # Create an array of times, starting at the current time, and extending # for len(x) number of hours. times = np.arange(len(x)) * 3600000 + time.time() source = ColumnDataSource( data=dict(x=x, y=y, times=times) ) xdr = DataRange1d(sources=[source.columns("times")]) ydr = DataRange1d(sources=[source.columns("y")]) circle = Circle(x="times", y="y", fill_color="red", size=5, line_color="black") glyph_renderer = Glyph( data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=circle, ) plot = Plot(x_range=xdr, y_range=ydr, data_sources=[source], min_border=80) xaxis = DatetimeAxis(plot=plot, dimension=0, location="min") yaxis = LinearAxis(plot=plot, dimension=1, location="min") pantool = PanTool(dimensions=["width", "height"]) wheelzoomtool = WheelZoomTool(dimensions=["width", "height"]) plot.renderers.append(glyph_renderer) plot.tools = [pantool, wheelzoomtool] doc = Document() doc.add(plot) if __name__ == "__main__": filename = "dateaxis.html" with open(filename, "w") as f: f.write(file_html(doc, INLINE, "Date Axis Example")) print("Wrote %s" % filename) view(filename)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 2680, 492, 6682, 12, 20461, 12, 9829, 199, 646, 2680, 465, 980, 199, 646, 900, 199, 199, 504, 25214, 14, 5750, 773, 492, 2455, 199, 504, 25214, 14, 3554, 492, 7543, 199, 504, 25214, 14, 6427, 492, 570, 63, 1360, 199, 504, 25214, 14, 13723, 83, 492, 445, 12571, 199, 504, 25214, 14, 1462, 492, 334, 10711, 12, 3918, 4709, 17, 68, 12, 12489, 11220, 12, 29825, 11220, 12, 267, 4996, 16693, 12, 598, 7234, 12, 510, 290, 5157, 12, 26161, 26798, 5157, 9, 199, 504, 25214, 14, 4435, 492, 1621, 6174, 199, 199, 88, 275, 20461, 2801, 18, 627, 6682, 12, 499, 627, 6682, 12, 378, 14, 17, 9, 199, 89, 275, 9829, 8, 88, 9, 199, 199, 3, 2790, 376, 1625, 402, 5431, 12, 6617, 737, 314, 1453, 900, 12, 436, 2178, 1098, 199, 3, 367, 822, 8, 88, 9, 1329, 402, 10857, 14, 199, 4508, 275, 980, 14, 5605, 8, 552, 8, 88, 430, 627, 8780, 5345, 435, 900, 14, 521, 342, 199, 199, 1365, 275, 4996, 16693, 8, 272, 666, 29, 807, 8, 88, 29, 88, 12, 612, 29, 89, 12, 5431, 29, 4508, 9, 199, 9, 199, 199, 2207, 82, 275, 3918, 4709, 17, 68, 8, 4553, 1524, 1365, 14, 3406, 480, 4508, 13403, 199, 89, 5012, 275, 3918, 4709, 17, 68, 8, 4553, 1524, 1365, 14, 3406, 480, 89, 13403, 199, 199, 11001, 275, 445, 12571, 8, 88, 628, 4508, 401, 612, 628, 89, 401, 5554, 63, 2326, 628, 581, 401, 1568, 29, 21, 12, 1004, 63, 2326, 628, 8399, 531, 199, 199, 13723, 63, 12471, 275, 598, 7234, 8, 272, 666, 63, 1365, 29, 1365, 12, 272, 671, 576, 63, 1842, 29, 2207, 82, 12, 272, 612, 576, 63, 1842, 29, 89, 5012, 12, 272, 14165, 29, 11001, 12, 199, 9, 199, 199, 2798, 275, 14794, 8, 88, 63, 1842, 29, 2207, 82, 12, 612, 63, 1842, 29, 89, 5012, 12, 666, 63, 4553, 1524, 1365, 467, 1748, 63, 8665, 29, 1257, 9, 199, 21854, 275, 29825, 11220, 8, 2798, 29, 2798, 12, 6240, 29, 16, 12, 2909, 628, 827, 531, 199, 23876, 275, 12489, 11220, 8, 2798, 29, 2798, 12, 6240, 29, 17, 12, 2909, 628, 827, 531, 199, 199, 10384, 3557, 275, 510, 290, 5157, 8, 13320, 6270, 2063, 401, 298, 3333, 3135, 199, 11798, 10598, 3557, 275, 26161, 26798, 5157, 8, 13320, 6270, 2063, 401, 298, 3333, 3135, 199, 199, 2798, 14, 828, 26529, 14, 740, 8, 13723, 63, 12471, 9, 199, 2798, 14, 2537, 275, 359, 10384, 3557, 12, 9989, 10598, 3557, 61, 199, 199, 1301, 275, 7543, 342, 199, 1301, 14, 525, 8, 2798, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1788, 275, 298, 602, 3127, 14, 1360, 2, 272, 543, 1551, 8, 1501, 12, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 8, 493, 63, 1360, 8, 1301, 12, 1621, 6174, 12, 298, 2506, 23205, 5679, 2237, 272, 870, 480, 55, 22665, 450, 83, 2, 450, 1788, 9, 272, 2455, 8, 1501, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 2680, 492, 6682, 12, 20461, 12, 9829, 199, 646, 2680, 465, 980, 199, 646, 900, 199, 199, 504, 25214, 14, 5750, 773, 492, 2455, 199, 504, 25214, 14, 3554, 492, 7543, 199, 504, 25214, 14, 6427, 492, 570, 63, 1360, 199, 504, 25214, 14, 13723, 83, 492, 445, 12571, 199, 504, 25214, 14, 1462, 492, 334, 10711, 12, 3918, 4709, 17, 68, 12, 12489, 11220, 12, 29825, 11220, 12, 267, 4996, 16693, 12, 598, 7234, 12, 510, 290, 5157, 12, 26161, 26798, 5157, 9, 199, 504, 25214, 14, 4435, 492, 1621, 6174, 199, 199, 88, 275, 20461, 2801, 18, 627, 6682, 12, 499, 627, 6682, 12, 378, 14, 17, 9, 199, 89, 275, 9829, 8, 88, 9, 199, 199, 3, 2790, 376, 1625, 402, 5431, 12, 6617, 737, 314, 1453, 900, 12, 436, 2178, 1098, 199, 3, 367, 822, 8, 88, 9, 1329, 402, 10857, 14, 199, 4508, 275, 980, 14, 5605, 8, 552, 8, 88, 430, 627, 8780, 5345, 435, 900, 14, 521, 342, 199, 199, 1365, 275, 4996, 16693, 8, 272, 666, 29, 807, 8, 88, 29, 88, 12, 612, 29, 89, 12, 5431, 29, 4508, 9, 199, 9, 199, 199, 2207, 82, 275, 3918, 4709, 17, 68, 8, 4553, 1524, 1365, 14, 3406, 480, 4508, 13403, 199, 89, 5012, 275, 3918, 4709, 17, 68, 8, 4553, 1524, 1365, 14, 3406, 480, 89, 13403, 199, 199, 11001, 275, 445, 12571, 8, 88, 628, 4508, 401, 612, 628, 89, 401, 5554, 63, 2326, 628, 581, 401, 1568, 29, 21, 12, 1004, 63, 2326, 628, 8399, 531, 199, 199, 13723, 63, 12471, 275, 598, 7234, 8, 272, 666, 63, 1365, 29, 1365, 12, 272, 671, 576, 63, 1842, 29, 2207, 82, 12, 272, 612, 576, 63, 1842, 29, 89, 5012, 12, 272, 14165, 29, 11001, 12, 199, 9, 199, 199, 2798, 275, 14794, 8, 88, 63, 1842, 29, 2207, 82, 12, 612, 63, 1842, 29, 89, 5012, 12, 666, 63, 4553, 1524, 1365, 467, 1748, 63, 8665, 29, 1257, 9, 199, 21854, 275, 29825, 11220, 8, 2798, 29, 2798, 12, 6240, 29, 16, 12, 2909, 628, 827, 531, 199, 23876, 275, 12489, 11220, 8, 2798, 29, 2798, 12, 6240, 29, 17, 12, 2909, 628, 827, 531, 199, 199, 10384, 3557, 275, 510, 290, 5157, 8, 13320, 6270, 2063, 401, 298, 3333, 3135, 199, 11798, 10598, 3557, 275, 26161, 26798, 5157, 8, 13320, 6270, 2063, 401, 298, 3333, 3135, 199, 199, 2798, 14, 828, 26529, 14, 740, 8, 13723, 63, 12471, 9, 199, 2798, 14, 2537, 275, 359, 10384, 3557, 12, 9989, 10598, 3557, 61, 199, 199, 1301, 275, 7543, 342, 199, 1301, 14, 525, 8, 2798, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1788, 275, 298, 602, 3127, 14, 1360, 2, 272, 543, 1551, 8, 1501, 12, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 8, 493, 63, 1360, 8, 1301, 12, 1621, 6174, 12, 298, 2506, 23205, 5679, 2237, 272, 870, 480, 55, 22665, 450, 83, 2, 450, 1788, 9, 272, 2455, 8, 1501, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
zoyahav/incubator-airflow
tests/contrib/operators/test_spark_submit_operator.py
10
5302
# -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import unittest import datetime import sys from airflow import DAG, configuration from airflow.models import TaskInstance from airflow.contrib.operators.spark_submit_operator import SparkSubmitOperator DEFAULT_DATE = datetime.datetime(2017, 1, 1) class TestSparkSubmitOperator(unittest.TestCase): _config = { 'conf': { 'parquet.compression': 'SNAPPY' }, 'files': 'hive-site.xml', 'py_files': 'sample_library.py', 'jars': 'parquet.jar', 'total_executor_cores':4, 'executor_cores': 4, 'executor_memory': '22g', 'keytab': 'privileged_user.keytab', 'principal': 'user/spark@airflow.org', 'name': '{{ task_instance.task_id }}', 'num_executors': 10, 'verbose': True, 'application': 'test_application.py', 'driver_memory': '3g', 'java_class': 'com.foo.bar.AppMain', 'application_args': [ '-f foo', '--bar bar', '--start {{ macros.ds_add(ds, -1)}}', '--end {{ ds }}' ] } def setUp(self): if sys.version_info[0] == 3: raise unittest.SkipTest('TestSparkSubmitOperator won\'t work with ' 'python3. No need to test anything here') configuration.load_test_config() args = { 'owner': 'airflow', 'start_date': DEFAULT_DATE } self.dag = DAG('test_dag_id', default_args=args) def test_execute(self): # Given / When conn_id = 'spark_default' operator = SparkSubmitOperator( task_id='spark_submit_job', dag=self.dag, **self._config ) # Then expected_dict = { 'conf': { 'parquet.compression': 'SNAPPY' }, 'files': 'hive-site.xml', 'py_files': 'sample_library.py', 'jars': 'parquet.jar', 'total_executor_cores': 4, 'executor_cores': 4, 'executor_memory': '22g', 'keytab': 'privileged_user.keytab', 'principal': 'user/spark@airflow.org', 'name': '{{ task_instance.task_id }}', 'num_executors': 10, 'verbose': True, 'application': 'test_application.py', 'driver_memory': '3g', 'java_class': 'com.foo.bar.AppMain', 'application_args': [ '-f foo', '--bar bar', '--start {{ macros.ds_add(ds, -1)}}', '--end {{ ds }}' ] } self.assertEqual(conn_id, operator._conn_id) self.assertEqual(expected_dict['application'], operator._application) self.assertEqual(expected_dict['conf'], operator._conf) self.assertEqual(expected_dict['files'], operator._files) self.assertEqual(expected_dict['py_files'], operator._py_files) self.assertEqual(expected_dict['jars'], operator._jars) self.assertEqual(expected_dict['total_executor_cores'], operator._total_executor_cores) self.assertEqual(expected_dict['executor_cores'], operator._executor_cores) self.assertEqual(expected_dict['executor_memory'], operator._executor_memory) self.assertEqual(expected_dict['keytab'], operator._keytab) self.assertEqual(expected_dict['principal'], operator._principal) self.assertEqual(expected_dict['name'], operator._name) self.assertEqual(expected_dict['num_executors'], operator._num_executors) self.assertEqual(expected_dict['verbose'], operator._verbose) self.assertEqual(expected_dict['java_class'], operator._java_class) self.assertEqual(expected_dict['driver_memory'], operator._driver_memory) self.assertEqual(expected_dict['application_args'], operator._application_args) def test_render_template(self): # Given operator = SparkSubmitOperator(task_id='spark_submit_job', dag=self.dag, **self._config) ti = TaskInstance(operator, DEFAULT_DATE) # When ti.render_templates() # Then expected_application_args = [u'-f foo', u'--bar bar', u'--start %s' % (DEFAULT_DATE - datetime.timedelta(days=1)).strftime("%Y-%m-%d"), u'--end %s' % DEFAULT_DATE.strftime("%Y-%m-%d")] expected_name = "spark_submit_job" self.assertListEqual(sorted(expected_application_args), sorted(getattr(operator, '_application_args'))) self.assertEqual(expected_name, getattr(operator, '_name')) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 2882, 199, 646, 2197, 199, 646, 984, 199, 199, 504, 16321, 492, 19666, 12, 2897, 199, 504, 16321, 14, 992, 492, 8495, 3244, 199, 199, 504, 16321, 14, 2828, 14, 12688, 14, 9852, 63, 7275, 63, 3856, 492, 13932, 17187, 7961, 199, 199, 3472, 63, 5390, 275, 2197, 14, 2083, 8, 10680, 12, 413, 12, 413, 9, 421, 199, 533, 1379, 27110, 17187, 7961, 8, 2796, 14, 1746, 304, 339, 485, 888, 275, 469, 267, 283, 2190, 356, 469, 288, 283, 462, 17917, 14, 12849, 356, 283, 22616, 4521, 7, 267, 1660, 267, 283, 1725, 356, 283, 17230, 13, 2124, 14, 1652, 297, 267, 283, 647, 63, 1725, 356, 283, 3271, 63, 4342, 14, 647, 297, 267, 283, 32262, 356, 283, 462, 17917, 14, 7338, 297, 267, 283, 2923, 63, 13471, 63, 4630, 356, 20, 12, 267, 283, 13471, 63, 4630, 356, 841, 12, 267, 283, 13471, 63, 4844, 356, 283, 1081, 71, 297, 267, 283, 498, 2902, 356, 283, 27672, 63, 751, 14, 498, 2902, 297, 267, 283, 19200, 356, 283, 751, 15, 9852, 32, 15815, 14, 1308, 297, 267, 283, 354, 356, 11400, 2120, 63, 842, 14, 1765, 63, 344, 23688, 267, 283, 1507, 63, 1628, 6622, 356, 1616, 12, 267, 283, 3832, 356, 715, 12, 267, 283, 3578, 356, 283, 396, 63, 3578, 14, 647, 297, 267, 283, 3090, 63, 4844, 356, 283, 19, 71, 297, 267, 283, 6138, 63, 533, 356, 283, 957, 14, 1421, 14, 1700, 14, 2640, 6756, 297, 267, 283, 3578, 63, 589, 356, 359, 288, 2475, 70, 3925, 297, 288, 2850, 1700, 4681, 297, 288, 2850, 928, 8448, 16954, 14, 795, 63, 525, 8, 795, 12, 446, 17, 9, 29223, 288, 2850, 500, 8448, 6364, 16339, 267, 1622, 272, 789, 339, 347, 3613, 8, 277, 304, 398, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 26, 288, 746, 2882, 14, 25755, 360, 774, 27110, 17187, 7961, 7859, 3985, 84, 1736, 543, 283, 2511, 283, 1548, 19, 14, 3091, 1929, 370, 511, 7003, 2348, 358, 398, 2897, 14, 912, 63, 396, 63, 888, 342, 267, 1249, 275, 469, 288, 283, 4597, 356, 283, 15815, 297, 288, 283, 928, 63, 602, 356, 6186, 63, 5390, 267, 789, 267, 291, 14, 7406, 275, 19666, 360, 396, 63, 7406, 63, 344, 297, 849, 63, 589, 29, 589, 9, 339, 347, 511, 63, 2526, 8, 277, 304, 267, 327, 9138, 1182, 3979, 267, 2557, 63, 344, 275, 283, 9852, 63, 885, 7, 267, 4182, 275, 13932, 17187, 7961, 8, 288, 2120, 63, 344, 534, 9852, 63, 7275, 63, 2423, 297, 288, 10158, 29, 277, 14, 7406, 12, 288, 1011, 277, 423, 888, 267, 776, 398, 327, 9442, 267, 1420, 63, 807, 275, 469, 288, 283, 2190, 356, 469, 355, 283, 462, 17917, 14, 12849, 356, 283, 22616, 4521, 7, 288, 1660, 288, 283, 1725, 356, 283, 17230, 13, 2124, 14, 1652, 297, 288, 283, 647, 63, 1725, 356, 283, 3271, 63, 4342, 14, 647, 297, 288, 283, 32262, 356, 283, 462, 17917, 14, 7338, 297, 288, 283, 2923, 63, 13471, 63, 4630, 356, 841, 12, 288, 283, 13471, 63, 4630, 356, 841, 12, 288, 283, 13471, 63, 4844, 356, 283, 1081, 71, 297, 288, 283, 498, 2902, 356, 283, 27672, 63, 751, 14, 498, 2902, 297, 288, 283, 19200, 356, 283, 751, 15, 9852, 32, 15815, 14, 1308, 297, 288, 283, 354, 356, 11400, 2120, 63, 842, 14, 1765, 63, 344, 23688, 288, 283, 1507, 63, 1628, 6622, 356, 1616, 12, 288, 283, 3832, 356, 715, 12, 288, 283, 3578, 356, 283, 396, 63, 3578, 14, 647, 297, 288, 283, 3090, 63, 4844, 356, 283, 19, 71, 297, 288, 283, 6138, 63, 533, 356, 283, 957, 14, 1421, 14, 1700, 14, 2640, 6756, 297, 288, 283, 3578, 63, 589, 356, 359, 355, 2475, 70, 3925, 297, 355, 2850, 1700, 4681, 297, 355, 2850, 928, 8448, 16954, 14, 795, 63, 525, 8, 795, 12, 446, 17, 9, 29223, 355, 2850, 500, 8448, 6364, 16339, 288, 1622, 398, 789, 398, 291, 14, 629, 8, 1631, 63, 344, 12, 4182, 423, 1631, 63, 344, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 3578, 995, 4182, 423, 3578, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 2190, 995, 4182, 423, 2190, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 1725, 995, 4182, 423, 1725, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 647, 63, 1725, 995, 4182, 423, 647, 63, 1725, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 32262, 995, 4182, 423, 32262, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 2923, 63, 13471, 63, 4630, 995, 4182, 423, 2923, 63, 13471, 63, 4630, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 13471, 63, 4630, 995, 4182, 423, 13471, 63, 4630, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 13471, 63, 4844, 995, 4182, 423, 13471, 63, 4844, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 498, 2902, 995, 4182, 423, 498, 2902, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 19200, 995, 4182, 423, 19200, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 354, 995, 4182, 423, 354, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 1507, 63, 1628, 6622, 995, 4182, 423 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 2882, 199, 646, 2197, 199, 646, 984, 199, 199, 504, 16321, 492, 19666, 12, 2897, 199, 504, 16321, 14, 992, 492, 8495, 3244, 199, 199, 504, 16321, 14, 2828, 14, 12688, 14, 9852, 63, 7275, 63, 3856, 492, 13932, 17187, 7961, 199, 199, 3472, 63, 5390, 275, 2197, 14, 2083, 8, 10680, 12, 413, 12, 413, 9, 421, 199, 533, 1379, 27110, 17187, 7961, 8, 2796, 14, 1746, 304, 339, 485, 888, 275, 469, 267, 283, 2190, 356, 469, 288, 283, 462, 17917, 14, 12849, 356, 283, 22616, 4521, 7, 267, 1660, 267, 283, 1725, 356, 283, 17230, 13, 2124, 14, 1652, 297, 267, 283, 647, 63, 1725, 356, 283, 3271, 63, 4342, 14, 647, 297, 267, 283, 32262, 356, 283, 462, 17917, 14, 7338, 297, 267, 283, 2923, 63, 13471, 63, 4630, 356, 20, 12, 267, 283, 13471, 63, 4630, 356, 841, 12, 267, 283, 13471, 63, 4844, 356, 283, 1081, 71, 297, 267, 283, 498, 2902, 356, 283, 27672, 63, 751, 14, 498, 2902, 297, 267, 283, 19200, 356, 283, 751, 15, 9852, 32, 15815, 14, 1308, 297, 267, 283, 354, 356, 11400, 2120, 63, 842, 14, 1765, 63, 344, 23688, 267, 283, 1507, 63, 1628, 6622, 356, 1616, 12, 267, 283, 3832, 356, 715, 12, 267, 283, 3578, 356, 283, 396, 63, 3578, 14, 647, 297, 267, 283, 3090, 63, 4844, 356, 283, 19, 71, 297, 267, 283, 6138, 63, 533, 356, 283, 957, 14, 1421, 14, 1700, 14, 2640, 6756, 297, 267, 283, 3578, 63, 589, 356, 359, 288, 2475, 70, 3925, 297, 288, 2850, 1700, 4681, 297, 288, 2850, 928, 8448, 16954, 14, 795, 63, 525, 8, 795, 12, 446, 17, 9, 29223, 288, 2850, 500, 8448, 6364, 16339, 267, 1622, 272, 789, 339, 347, 3613, 8, 277, 304, 398, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 26, 288, 746, 2882, 14, 25755, 360, 774, 27110, 17187, 7961, 7859, 3985, 84, 1736, 543, 283, 2511, 283, 1548, 19, 14, 3091, 1929, 370, 511, 7003, 2348, 358, 398, 2897, 14, 912, 63, 396, 63, 888, 342, 267, 1249, 275, 469, 288, 283, 4597, 356, 283, 15815, 297, 288, 283, 928, 63, 602, 356, 6186, 63, 5390, 267, 789, 267, 291, 14, 7406, 275, 19666, 360, 396, 63, 7406, 63, 344, 297, 849, 63, 589, 29, 589, 9, 339, 347, 511, 63, 2526, 8, 277, 304, 267, 327, 9138, 1182, 3979, 267, 2557, 63, 344, 275, 283, 9852, 63, 885, 7, 267, 4182, 275, 13932, 17187, 7961, 8, 288, 2120, 63, 344, 534, 9852, 63, 7275, 63, 2423, 297, 288, 10158, 29, 277, 14, 7406, 12, 288, 1011, 277, 423, 888, 267, 776, 398, 327, 9442, 267, 1420, 63, 807, 275, 469, 288, 283, 2190, 356, 469, 355, 283, 462, 17917, 14, 12849, 356, 283, 22616, 4521, 7, 288, 1660, 288, 283, 1725, 356, 283, 17230, 13, 2124, 14, 1652, 297, 288, 283, 647, 63, 1725, 356, 283, 3271, 63, 4342, 14, 647, 297, 288, 283, 32262, 356, 283, 462, 17917, 14, 7338, 297, 288, 283, 2923, 63, 13471, 63, 4630, 356, 841, 12, 288, 283, 13471, 63, 4630, 356, 841, 12, 288, 283, 13471, 63, 4844, 356, 283, 1081, 71, 297, 288, 283, 498, 2902, 356, 283, 27672, 63, 751, 14, 498, 2902, 297, 288, 283, 19200, 356, 283, 751, 15, 9852, 32, 15815, 14, 1308, 297, 288, 283, 354, 356, 11400, 2120, 63, 842, 14, 1765, 63, 344, 23688, 288, 283, 1507, 63, 1628, 6622, 356, 1616, 12, 288, 283, 3832, 356, 715, 12, 288, 283, 3578, 356, 283, 396, 63, 3578, 14, 647, 297, 288, 283, 3090, 63, 4844, 356, 283, 19, 71, 297, 288, 283, 6138, 63, 533, 356, 283, 957, 14, 1421, 14, 1700, 14, 2640, 6756, 297, 288, 283, 3578, 63, 589, 356, 359, 355, 2475, 70, 3925, 297, 355, 2850, 1700, 4681, 297, 355, 2850, 928, 8448, 16954, 14, 795, 63, 525, 8, 795, 12, 446, 17, 9, 29223, 355, 2850, 500, 8448, 6364, 16339, 288, 1622, 398, 789, 398, 291, 14, 629, 8, 1631, 63, 344, 12, 4182, 423, 1631, 63, 344, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 3578, 995, 4182, 423, 3578, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 2190, 995, 4182, 423, 2190, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 1725, 995, 4182, 423, 1725, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 647, 63, 1725, 995, 4182, 423, 647, 63, 1725, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 32262, 995, 4182, 423, 32262, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 2923, 63, 13471, 63, 4630, 995, 4182, 423, 2923, 63, 13471, 63, 4630, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 13471, 63, 4630, 995, 4182, 423, 13471, 63, 4630, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 13471, 63, 4844, 995, 4182, 423, 13471, 63, 4844, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 498, 2902, 995, 4182, 423, 498, 2902, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 19200, 995, 4182, 423, 19200, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 354, 995, 4182, 423, 354, 9, 267, 291, 14, 629, 8, 2062, 63, 807, 459, 1507, 63, 1628, 6622, 995, 4182, 423, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # aDBa is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with aDBa. If not, see <http://www.gnu.org/licenses/>. from __future__ import with_statement import os, re, string from time import time, sleep import aniDBfileInfo as fileInfo from aniDBmaper import AniDBMaper from aniDBtvDBmaper import TvDBMap from aniDBerrors import * from aniDBfileInfo import read_anidb_xml, read_tvdb_map_xml try: import xml.etree.cElementTree as etree except ImportError: import xml.etree.ElementTree as etree class aniDBabstractObject(object): def __init__(self, aniDB, load=False): self.laoded = False self.set_connection(aniDB) if load: self.load_data() def set_connection(self, aniDB): self.aniDB = aniDB if self.aniDB: self.log = self.aniDB.log else: self.log = self._fake_log() def _fake_log(self, x=None): pass def _fill(self, dataline): for key in dataline: try: tmpList = dataline[key].split("'") if len(tmpList) > 1: newList = [] for i in tmpList: try: newList.append(int(i)) except: newList.append(unicode(i, "utf-8")) self.__dict__[key] = newList continue except: pass try: self.__dict__[key] = int(dataline[key]) except: self.__dict__[key] = unicode(dataline[key], "utf-8") key = property(lambda x: dataline[key]) def __getattr__(self, name): try: return object.__getattribute__(self, name) except: return None def _build_names(self): names = [] names = self._easy_extend(names, self.english_name) names = self._easy_extend(names, self.short_name_list) names = self._easy_extend(names, self.synonym_list) names = self._easy_extend(names, self.other_name) self.allNames = names def _easy_extend(self, initialList, item): if item: if isinstance(item, list): initialList.extend(item) elif isinstance(item, basestring): initialList.append(item) return initialList def load_data(self): return False def add_notification(self): """ type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete priority - low = 0, medium = 1, high = 2 (unconfirmed) """ if self.aid: self.aniDB.notifyadd(aid=self.aid, type=1, priority=1) def del_notification(self): """ type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete priority - low = 0, medium = 1, high = 2 (unconfirmed) """ if self.aid: self.aniDB.notifydel(aid=self.aid, type=1, priority=1) class Anime(aniDBabstractObject): def __init__(self, aniDB, name=None, aid=None, tvdbid=None, paramsA=None, autoCorrectName=False, load=False): self.maper = AniDBMaper() self.tvDBMap = TvDBMap() self.allAnimeXML = None self.name = name self.aid = aid self.tvdb_id = tvdbid if self.tvdb_id and not self.aid: self.aid = self.tvDBMap.get_anidb_for_tvdb(self.tvdb_id) if not (self.name or self.aid): raise AniDBIncorrectParameterError("No aid or name available") if not self.aid: self.aid = self._get_aid_from_xml(self.name) if not self.name or autoCorrectName: self.name = self._get_name_from_xml(self.aid) if not (self.name or self.aid): raise ValueError if not self.tvdb_id: self.tvdb_id = self.tvDBMap.get_tvdb_for_anidb(self.aid) if not paramsA: self.bitCode = "b2f0e0fc000000" self.params = self.maper.getAnimeCodesA(self.bitCode) else: self.paramsA = paramsA self.bitCode = self.maper.getAnimeBitsA(self.paramsA) super(Anime, self).__init__(aniDB, load) def load_data(self): """load the data from anidb""" if not (self.name or self.aid): raise ValueError self.rawData = self.aniDB.anime(aid=self.aid, aname=self.name, amask=self.bitCode) if self.rawData.datalines: self._fill(self.rawData.datalines[0]) self._builPreSequal() self.laoded = True def get_groups(self): if not self.aid: return [] self.rawData = self.aniDB.groupstatus(aid=self.aid) self.release_groups = [] for line in self.rawData.datalines: self.release_groups.append({"name": unicode(line["name"], "utf-8"), "rating": line["rating"], "range": line["episode_range"] }) return self.release_groups # TODO: refactor and use the new functions in anidbFileinfo def _get_aid_from_xml(self, name): if not self.allAnimeXML: self.allAnimeXML = read_anidb_xml() regex = re.compile( '( \(\d{4}\))|[%s]' % re.escape(string.punctuation)) # remove any punctuation and e.g. ' (2011)' #regex = re.compile('[%s]' % re.escape(string.punctuation)) # remove any punctuation and e.g. ' (2011)' name = regex.sub('', name.lower()) lastAid = 0 for element in self.allAnimeXML.getiterator(): if element.get("aid", False): lastAid = int(element.get("aid")) if element.text: testname = regex.sub('', element.text.lower()) if testname == name: return lastAid return 0 #TODO: refactor and use the new functions in anidbFileinfo def _get_name_from_xml(self, aid, onlyMain=True): if not self.allAnimeXML: self.allAnimeXML = read_anidb_xml() for anime in self.allAnimeXML.findall("anime"): if int(anime.get("aid", False)) == aid: for title in anime.getiterator(): currentLang = title.get("{http://www.w3.org/XML/1998/namespace}lang", False) currentType = title.get("type", False) if (currentLang == "en" and not onlyMain) or currentType == "main": return title.text return "" def _builPreSequal(self): if self.related_aid_list and self.related_aid_type: try: for i in range(len(self.related_aid_list)): if self.related_aid_type[i] == 2: self.__dict__["prequal"] = self.related_aid_list[i] elif self.related_aid_type[i] == 1: self.__dict__["sequal"] = self.related_aid_list[i] except: if self.related_aid_type == 2: self.__dict__["prequal"] = self.related_aid_list elif self.str_related_aid_type == 1: self.__dict__["sequal"] = self.related_aid_list class Episode(aniDBabstractObject): def __init__(self, aniDB, number=None, epid=None, filePath=None, fid=None, epno=None, paramsA=None, paramsF=None, load=False, calculate=False): self.maper = AniDBMaper() self.epid = epid self.filePath = filePath self.fid = fid self.epno = epno if calculate: (self.ed2k, self.size) = self._calculate_file_stuff(self.filePath) if not paramsA: self.bitCodeA = "C000F0C0" self.paramsA = self.maper.getFileCodesA(self.bitCodeA) else: self.paramsA = paramsA self.bitCodeA = self.maper.getFileBitsA(self.paramsA) if not paramsF: self.bitCodeF = "7FF8FEF8" self.paramsF = self.maper.getFileCodesF(self.bitCodeF) else: self.paramsF = paramsF self.bitCodeF = self.maper.getFileBitsF(self.paramsF) super(Episode, self).__init__(aniDB, load) def load_data(self): """load the data from anidb""" if self.filePath and not (self.ed2k or self.size): (self.ed2k, self.size) = self._calculate_file_stuff(self.filePath) self.rawData = self.aniDB.file(fid=self.fid, size=self.size, ed2k=self.ed2k, aid=self.aid, aname=None, gid=None, gname=None, epno=self.epno, fmask=self.bitCodeF, amask=self.bitCodeA) self._fill(self.rawData.datalines[0]) self._build_names() self.laoded = True def add_to_mylist(self, status=None): """ status: 0 unknown - state is unknown or the user doesn't want to provide this information (default) 1 on hdd - the file is stored on hdd 2 on cd - the file is stored on cd 3 deleted - the file has been deleted or is not available for other reasons (i.e. reencoded) """ if self.filePath and not (self.ed2k or self.size): (self.ed2k, self.size) = self._calculate_file_stuff(self.filePath) try: self.aniDB.mylistadd(size=self.size, ed2k=self.ed2k, state=status) except Exception, e: self.log(u"exception msg: " + str(e)) else: # TODO: add the name or something self.log(u"Added the episode to anidb") def _calculate_file_stuff(self, filePath): if not filePath: return (None, None) self.log("Calculating the ed2k. Please wait...") ed2k = fileInfo.get_file_hash(filePath) size = fileInfo.get_file_size(filePath) return (ed2k, size)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 282, 2846, 65, 14, 199, 3, 199, 3, 282, 2846, 65, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 282, 2846, 65, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 282, 2846, 65, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 747, 12, 295, 12, 1059, 199, 504, 900, 492, 900, 12, 9435, 199, 199, 646, 376, 73, 2846, 493, 2354, 465, 570, 2354, 199, 504, 376, 73, 2846, 391, 529, 492, 1626, 73, 2846, 2956, 281, 199, 504, 376, 73, 2846, 6993, 2846, 391, 529, 492, 377, 86, 2846, 2956, 199, 504, 376, 73, 2846, 2550, 492, 627, 199, 504, 376, 73, 2846, 493, 2354, 492, 1586, 63, 290, 344, 66, 63, 1652, 12, 1586, 63, 23625, 63, 1130, 63, 1652, 199, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 67, 15325, 465, 7559, 199, 2590, 3545, 26, 272, 492, 2748, 14, 9464, 14, 15325, 465, 7559, 199, 199, 533, 376, 73, 2846, 6198, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 376, 73, 2846, 12, 2248, 29, 797, 304, 267, 291, 14, 416, 380, 68, 275, 756, 267, 291, 14, 409, 63, 2105, 8, 26455, 2846, 9, 267, 340, 2248, 26, 288, 291, 14, 912, 63, 576, 342, 339, 347, 663, 63, 2105, 8, 277, 12, 376, 73, 2846, 304, 267, 291, 14, 26455, 2846, 275, 376, 73, 2846, 267, 340, 291, 14, 26455, 2846, 26, 288, 291, 14, 793, 275, 291, 14, 26455, 2846, 14, 793, 267, 587, 26, 288, 291, 14, 793, 275, 291, 423, 3183, 63, 793, 342, 339, 347, 485, 3183, 63, 793, 8, 277, 12, 671, 29, 403, 304, 267, 986, 339, 347, 485, 4498, 8, 277, 12, 6394, 279, 1132, 304, 267, 367, 790, 315, 6394, 279, 1132, 26, 288, 862, 26, 355, 3529, 1296, 275, 6394, 279, 1132, 59, 498, 1055, 1294, 480, 9859, 355, 340, 822, 8, 2791, 1296, 9, 690, 413, 26, 490, 892, 1296, 275, 942, 490, 367, 284, 315, 3529, 1296, 26, 717, 862, 26, 1169, 892, 1296, 14, 740, 8, 442, 8, 73, 430, 717, 871, 26, 1169, 892, 1296, 14, 740, 8, 2975, 8, 73, 12, 298, 1624, 13, 24, 2237, 490, 291, 855, 807, 12298, 498, 61, 275, 892, 1296, 490, 1980, 288, 871, 26, 355, 986, 288, 862, 26, 355, 291, 855, 807, 12298, 498, 61, 275, 1109, 8, 4616, 279, 1132, 59, 498, 566, 288, 871, 26, 355, 291, 855, 807, 12298, 498, 61, 275, 2649, 8, 4616, 279, 1132, 59, 498, 467, 298, 1624, 13, 24, 531, 288, 790, 275, 3324, 8, 2734, 671, 26, 6394, 279, 1132, 59, 498, 566, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 862, 26, 288, 372, 909, 855, 18480, 721, 277, 12, 536, 9, 267, 871, 26, 288, 372, 488, 339, 347, 485, 1506, 63, 1247, 8, 277, 304, 267, 1561, 275, 942, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 17872, 63, 354, 9, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 3612, 63, 354, 63, 513, 9, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 9466, 15224, 63, 513, 9, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 1848, 63, 354, 9, 398, 291, 14, 452, 5866, 275, 1561, 339, 347, 485, 13581, 63, 2880, 8, 277, 12, 2536, 1296, 12, 1242, 304, 267, 340, 1242, 26, 288, 340, 1228, 8, 1053, 12, 769, 304, 355, 2536, 1296, 14, 2880, 8, 1053, 9, 288, 916, 1228, 8, 1053, 12, 7116, 304, 355, 2536, 1296, 14, 740, 8, 1053, 9, 398, 372, 2536, 1296, 2378, 347, 2248, 63, 576, 8, 277, 304, 267, 372, 756, 339, 347, 1050, 63, 6761, 8, 277, 304, 267, 408, 267, 730, 446, 2434, 402, 6955, 26, 730, 28266, 221, 378, 29, 452, 12, 413, 29, 1222, 12, 499, 29, 923, 12, 650, 29, 4883, 267, 7464, 446, 6465, 275, 378, 12, 21576, 275, 413, 12, 4721, 275, 499, 334, 324, 16391, 9, 398, 408, 267, 340, 291, 14, 21745, 26, 288, 291, 14, 26455, 2846, 14, 6814, 525, 8, 21745, 29, 277, 14, 21745, 12, 730, 29, 17, 12, 7464, 29, 17, 9, 339, 347, 2150, 63, 6761, 8, 277, 304, 267, 408, 267, 730, 446, 2434, 402, 6955, 26, 730, 28266, 221, 378, 29, 452, 12, 413, 29, 1222, 12, 499, 29, 923, 12, 650, 29, 4883, 267, 7464, 446, 6465, 275, 378, 12, 21576, 275, 413, 12, 4721, 275, 499, 334, 324, 16391, 9, 398, 408, 267, 340, 291, 14, 21745, 26, 288, 291, 14, 26455, 2846, 14, 6814, 2264, 8, 21745, 29, 277, 14, 21745, 12, 730, 29, 17, 12, 7464, 29, 17, 9, 421, 199, 533, 1626, 1036, 8, 26455, 2846, 6198, 1692, 304, 272, 347, 636, 826, 721, 277, 12, 376, 73, 2846, 12, 536, 29, 403, 12, 23939, 29, 403, 12, 26905, 344, 29, 403, 12, 1862, 33, 29, 403, 12, 2599, 19993, 985, 29, 797, 12, 2248, 29, 797, 304, 398, 291, 14, 391, 529, 275, 1626, 73, 2846, 2956, 281, 342, 267, 291, 14, 6993, 2846, 2956, 275, 377, 86, 2846, 2956, 342, 267, 291, 14, 452, 2493, 1036, 4317, 275, 488, 398, 291, 14, 354, 275, 536, 267, 291, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 282, 2846, 65, 14, 199, 3, 199, 3, 282, 2846, 65, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 282, 2846, 65, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 282, 2846, 65, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 747, 12, 295, 12, 1059, 199, 504, 900, 492, 900, 12, 9435, 199, 199, 646, 376, 73, 2846, 493, 2354, 465, 570, 2354, 199, 504, 376, 73, 2846, 391, 529, 492, 1626, 73, 2846, 2956, 281, 199, 504, 376, 73, 2846, 6993, 2846, 391, 529, 492, 377, 86, 2846, 2956, 199, 504, 376, 73, 2846, 2550, 492, 627, 199, 504, 376, 73, 2846, 493, 2354, 492, 1586, 63, 290, 344, 66, 63, 1652, 12, 1586, 63, 23625, 63, 1130, 63, 1652, 199, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 67, 15325, 465, 7559, 199, 2590, 3545, 26, 272, 492, 2748, 14, 9464, 14, 15325, 465, 7559, 199, 199, 533, 376, 73, 2846, 6198, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 376, 73, 2846, 12, 2248, 29, 797, 304, 267, 291, 14, 416, 380, 68, 275, 756, 267, 291, 14, 409, 63, 2105, 8, 26455, 2846, 9, 267, 340, 2248, 26, 288, 291, 14, 912, 63, 576, 342, 339, 347, 663, 63, 2105, 8, 277, 12, 376, 73, 2846, 304, 267, 291, 14, 26455, 2846, 275, 376, 73, 2846, 267, 340, 291, 14, 26455, 2846, 26, 288, 291, 14, 793, 275, 291, 14, 26455, 2846, 14, 793, 267, 587, 26, 288, 291, 14, 793, 275, 291, 423, 3183, 63, 793, 342, 339, 347, 485, 3183, 63, 793, 8, 277, 12, 671, 29, 403, 304, 267, 986, 339, 347, 485, 4498, 8, 277, 12, 6394, 279, 1132, 304, 267, 367, 790, 315, 6394, 279, 1132, 26, 288, 862, 26, 355, 3529, 1296, 275, 6394, 279, 1132, 59, 498, 1055, 1294, 480, 9859, 355, 340, 822, 8, 2791, 1296, 9, 690, 413, 26, 490, 892, 1296, 275, 942, 490, 367, 284, 315, 3529, 1296, 26, 717, 862, 26, 1169, 892, 1296, 14, 740, 8, 442, 8, 73, 430, 717, 871, 26, 1169, 892, 1296, 14, 740, 8, 2975, 8, 73, 12, 298, 1624, 13, 24, 2237, 490, 291, 855, 807, 12298, 498, 61, 275, 892, 1296, 490, 1980, 288, 871, 26, 355, 986, 288, 862, 26, 355, 291, 855, 807, 12298, 498, 61, 275, 1109, 8, 4616, 279, 1132, 59, 498, 566, 288, 871, 26, 355, 291, 855, 807, 12298, 498, 61, 275, 2649, 8, 4616, 279, 1132, 59, 498, 467, 298, 1624, 13, 24, 531, 288, 790, 275, 3324, 8, 2734, 671, 26, 6394, 279, 1132, 59, 498, 566, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 862, 26, 288, 372, 909, 855, 18480, 721, 277, 12, 536, 9, 267, 871, 26, 288, 372, 488, 339, 347, 485, 1506, 63, 1247, 8, 277, 304, 267, 1561, 275, 942, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 17872, 63, 354, 9, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 3612, 63, 354, 63, 513, 9, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 9466, 15224, 63, 513, 9, 267, 1561, 275, 291, 423, 13581, 63, 2880, 8, 1247, 12, 291, 14, 1848, 63, 354, 9, 398, 291, 14, 452, 5866, 275, 1561, 339, 347, 485, 13581, 63, 2880, 8, 277, 12, 2536, 1296, 12, 1242, 304, 267, 340, 1242, 26, 288, 340, 1228, 8, 1053, 12, 769, 304, 355, 2536, 1296, 14, 2880, 8, 1053, 9, 288, 916, 1228, 8, 1053, 12, 7116, 304, 355, 2536, 1296, 14, 740, 8, 1053, 9, 398, 372, 2536, 1296, 2378, 347, 2248, 63, 576, 8, 277, 304, 267, 372, 756, 339, 347, 1050, 63, 6761, 8, 277, 304, 267, 408, 267, 730, 446, 2434, 402, 6955, 26, 730, 28266, 221, 378, 29, 452, 12, 413, 29, 1222, 12, 499, 29, 923, 12, 650, 29, 4883, 267, 7464, 446, 6465, 275, 378, 12, 21576, 275, 413, 12, 4721, 275, 499, 334, 324, 16391, 9, 398, 408, 267, 340, 291, 14, 21745, 26, 288, 291, 14, 26455, 2846, 14, 6814, 525, 8, 21745, 29, 277, 14, 21745, 12, 730, 29, 17, 12, 7464, 29, 17, 9, 339, 347, 2150, 63, 6761, 8, 277, 304, 267, 408, 267, 730, 446, 2434, 402, 6955, 26, 730, 28266, 221, 378, 29, 452, 12, 413, 29, 1222, 12, 499, 29, 923, 12, 650, 29, 4883, 267, 7464, 446, 6465, 275, 378, 12, 21576, 275, 413, 12, 4721, 275, 499, 334, 324, 16391, 9, 398, 408, 267, 340, 291, 14, 21745, 26, 288, 291, 14, 26455, 2846, 14, 6814, 2264, 8, 21745, 29, 277, 14, 21745, 12, 730, 29, 17, 12, 7464, 29, 17, 9, 421, 199, 533, 1626, 1036, 8, 26455, 2846, 6198, 1692, 304, 272, 347, 636, 826, 721, 277, 12, 376, 73, 2846, 12, 536, 29, 403, 12, 23939, 29, 403, 12, 26905, 344, 29, 403, 12, 1862, 33, 29, 403, 12, 2599, 19993, 985, 29, 797, 12, 2248, 29, 797, 304, 398, 291, 14, 391, 529, 275, 1626, 73, 2846, 2956, 281, 342, 267, 291, 14, 6993, 2846, 2956, 275, 377, 86, 2846, 2956, 342, 267, 291, 14, 452, 2493, 1036, 4317, 275, 488, 398, 291, 14, 354, 275, 536, 267, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
praveenaki/zulip
zerver/management/commands/process_queue.py
120
1460
from __future__ import absolute_import from django.core.management.base import BaseCommand from django.core.management import CommandError from django.conf import settings from zerver.worker.queue_processors import get_worker import sys import signal import logging class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('queue_name', metavar='<queue name>', type=str, help="queue to process") parser.add_argument('worker_num', metavar='<worker number>', type=int, nargs='?', default=0, help="worker label") help = "Runs a queue processing worker" def handle(self, *args, **options): logging.basicConfig() logger = logging.getLogger('process_queue') queue_name = options['queue_name'] worker_num = options['worker_num'] def signal_handler(signal, frame): logger.info("Worker %d disconnecting from queue %s" % (worker_num, queue_name)) worker.stop() sys.exit(0) if not settings.USING_RABBITMQ: logger.error("Cannot run a queue processor when USING_RABBITMQ is False!") sys.exit(1) signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGINT, signal_handler) logger.info("Worker %d connecting to queue %s" % (worker_num, queue_name)) worker = get_worker(queue_name) worker.start()
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 504, 1639, 14, 1018, 14, 8110, 492, 14393, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 19959, 14, 6599, 14, 1825, 63, 10547, 492, 664, 63, 6599, 199, 646, 984, 199, 646, 4673, 199, 646, 2050, 199, 199, 533, 5817, 8, 25150, 304, 272, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 360, 1825, 63, 354, 297, 8214, 15829, 1825, 536, 4206, 730, 29, 495, 12, 1169, 1720, 628, 1825, 370, 2112, 531, 267, 1798, 14, 525, 63, 2094, 360, 6599, 63, 1507, 297, 8214, 15829, 6599, 1329, 4206, 730, 29, 442, 12, 9237, 31468, 849, 29, 16, 12, 1169, 1720, 628, 6599, 1768, 531, 339, 1720, 275, 298, 16291, 282, 4126, 6661, 7239, 2, 272, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 2050, 14, 19602, 342, 267, 2512, 275, 2050, 14, 5572, 360, 1412, 63, 1825, 358, 398, 4126, 63, 354, 275, 1511, 459, 1825, 63, 354, 418, 267, 7239, 63, 1507, 275, 1511, 459, 6599, 63, 1507, 418, 398, 347, 4673, 63, 2232, 8, 4653, 12, 2787, 304, 288, 2512, 14, 815, 480, 12678, 450, 68, 17639, 316, 687, 4126, 450, 83, 2, 450, 334, 6599, 63, 1507, 12, 4126, 63, 354, 430, 288, 7239, 14, 2379, 342, 288, 984, 14, 2224, 8, 16, 9, 398, 340, 440, 2202, 14, 1668, 1206, 63, 50, 1217, 11970, 14449, 26, 288, 2512, 14, 705, 480, 6612, 1255, 282, 4126, 12495, 1380, 32210, 63, 50, 1217, 11970, 14449, 365, 756, 9124, 288, 984, 14, 2224, 8, 17, 9, 398, 4673, 14, 4653, 8, 4653, 14, 29190, 12, 4673, 63, 2232, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 4673, 63, 2232, 9, 398, 2512, 14, 815, 480, 12678, 450, 68, 18170, 370, 4126, 450, 83, 2, 450, 334, 6599, 63, 1507, 12, 4126, 63, 354, 430, 267, 7239, 275, 664, 63, 6599, 8, 1825, 63, 354, 9, 267, 7239, 14, 928, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 504, 1639, 14, 1018, 14, 8110, 492, 14393, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 19959, 14, 6599, 14, 1825, 63, 10547, 492, 664, 63, 6599, 199, 646, 984, 199, 646, 4673, 199, 646, 2050, 199, 199, 533, 5817, 8, 25150, 304, 272, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 360, 1825, 63, 354, 297, 8214, 15829, 1825, 536, 4206, 730, 29, 495, 12, 1169, 1720, 628, 1825, 370, 2112, 531, 267, 1798, 14, 525, 63, 2094, 360, 6599, 63, 1507, 297, 8214, 15829, 6599, 1329, 4206, 730, 29, 442, 12, 9237, 31468, 849, 29, 16, 12, 1169, 1720, 628, 6599, 1768, 531, 339, 1720, 275, 298, 16291, 282, 4126, 6661, 7239, 2, 272, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 2050, 14, 19602, 342, 267, 2512, 275, 2050, 14, 5572, 360, 1412, 63, 1825, 358, 398, 4126, 63, 354, 275, 1511, 459, 1825, 63, 354, 418, 267, 7239, 63, 1507, 275, 1511, 459, 6599, 63, 1507, 418, 398, 347, 4673, 63, 2232, 8, 4653, 12, 2787, 304, 288, 2512, 14, 815, 480, 12678, 450, 68, 17639, 316, 687, 4126, 450, 83, 2, 450, 334, 6599, 63, 1507, 12, 4126, 63, 354, 430, 288, 7239, 14, 2379, 342, 288, 984, 14, 2224, 8, 16, 9, 398, 340, 440, 2202, 14, 1668, 1206, 63, 50, 1217, 11970, 14449, 26, 288, 2512, 14, 705, 480, 6612, 1255, 282, 4126, 12495, 1380, 32210, 63, 50, 1217, 11970, 14449, 365, 756, 9124, 288, 984, 14, 2224, 8, 17, 9, 398, 4673, 14, 4653, 8, 4653, 14, 29190, 12, 4673, 63, 2232, 9, 267, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 4673, 63, 2232, 9, 398, 2512, 14, 815, 480, 12678, 450, 68, 18170, 370, 4126, 450, 83, 2, 450, 334, 6599, 63, 1507, 12, 4126, 63, 354, 430, 267, 7239, 275, 664, 63, 6599, 8, 1825, 63, 354, 9, 267, 7239, 14, 928, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Definition of targets to build artifacts.""" import os.path import random import string import sys sys.path.insert(0, os.path.abspath('..')) import python_utils.jobset as jobset def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={}, flake_retries=0, timeout_retries=0, timeout_seconds=30 * 60, docker_base_image=None, extra_docker_args=None, verbose_success=False): """Creates jobspec for a task running under docker.""" environ = environ.copy() environ['RUN_COMMAND'] = shell_command environ['ARTIFACTS_OUT'] = 'artifacts/%s' % name docker_args = [] for k, v in environ.items(): docker_args += ['-e', '%s=%s' % (k, v)] docker_env = { 'DOCKERFILE_DIR': dockerfile_dir, 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh', 'OUTPUT_DIR': 'artifacts' } if docker_base_image is not None: docker_env['DOCKER_BASE_IMAGE'] = docker_base_image if extra_docker_args is not None: docker_env['EXTRA_DOCKER_ARGS'] = extra_docker_args jobspec = jobset.JobSpec( cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args, environ=docker_env, shortname='build_artifact.%s' % (name), timeout_seconds=timeout_seconds, flake_retries=flake_retries, timeout_retries=timeout_retries, verbose_success=verbose_success) return jobspec def create_jobspec(name, cmdline, environ={}, shell=False, flake_retries=0, timeout_retries=0, timeout_seconds=30 * 60, use_workspace=False, cpu_cost=1.0, verbose_success=False): """Creates jobspec.""" environ = environ.copy() if use_workspace: environ['WORKSPACE_NAME'] = 'workspace_%s' % name environ['ARTIFACTS_OUT'] = os.path.join('..', 'artifacts', name) cmdline = ['bash', 'tools/run_tests/artifacts/run_in_workspace.sh' ] + cmdline else: environ['ARTIFACTS_OUT'] = os.path.join('artifacts', name) jobspec = jobset.JobSpec( cmdline=cmdline, environ=environ, shortname='build_artifact.%s' % (name), timeout_seconds=timeout_seconds, flake_retries=flake_retries, timeout_retries=timeout_retries, shell=shell, cpu_cost=cpu_cost, verbose_success=verbose_success) return jobspec _MACOS_COMPAT_FLAG = '-mmacosx-version-min=10.7' _ARCH_FLAG_MAP = {'x86': '-m32', 'x64': '-m64'} class PythonArtifact: """Builds Python artifacts.""" def __init__(self, platform, arch, py_version): self.name = 'python_%s_%s_%s' % (platform, arch, py_version) self.platform = platform self.arch = arch self.labels = ['artifact', 'python', platform, arch, py_version] self.py_version = py_version def pre_build_jobspecs(self): return [] def build_jobspec(self): environ = {} if self.platform == 'linux_extra': # Raspberry Pi build environ['PYTHON'] = '/usr/local/bin/python{}'.format( self.py_version) environ['PIP'] = '/usr/local/bin/pip{}'.format(self.py_version) # https://github.com/resin-io-projects/armv7hf-debian-qemu/issues/9 # A QEMU bug causes submodule update to hang, so we copy directly environ['RELATIVE_COPY_PATH'] = '.' extra_args = ' --entrypoint=/usr/bin/qemu-arm-static ' return create_docker_jobspec( self.name, 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), 'tools/run_tests/artifacts/build_artifact_python.sh', environ=environ, timeout_seconds=60 * 60 * 5, docker_base_image='quay.io/grpc/raspbian_{}'.format(self.arch), extra_docker_args=extra_args) elif self.platform == 'linux': if self.arch == 'x86': environ['SETARCH_CMD'] = 'linux32' # Inside the manylinux container, the python installations are located in # special places... environ['PYTHON'] = '/opt/python/{}/bin/python'.format( self.py_version) environ['PIP'] = '/opt/python/{}/bin/pip'.format(self.py_version) # Platform autodetection for the manylinux1 image breaks so we set the # defines ourselves. # TODO(atash) get better platform-detection support in core so we don't # need to do this manually... environ['CFLAGS'] = '-DGPR_MANYLINUX1=1' environ['GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS'] = 'TRUE' environ['GRPC_BUILD_MANYLINUX_WHEEL'] = 'TRUE' return create_docker_jobspec( self.name, 'tools/dockerfile/grpc_artifact_python_manylinux_%s' % self.arch, 'tools/run_tests/artifacts/build_artifact_python.sh', environ=environ, timeout_seconds=60 * 60, docker_base_image='quay.io/pypa/manylinux1_i686' if self.arch == 'x86' else 'quay.io/pypa/manylinux1_x86_64') elif self.platform == 'windows': if 'Python27' in self.py_version or 'Python34' in self.py_version: environ['EXT_COMPILER'] = 'mingw32' else: environ['EXT_COMPILER'] = 'msvc' # For some reason, the batch script %random% always runs with the same # seed. We create a random temp-dir here dir = ''.join( random.choice(string.ascii_uppercase) for _ in range(10)) return create_jobspec( self.name, [ 'tools\\run_tests\\artifacts\\build_artifact_python.bat', self.py_version, '32' if self.arch == 'x86' else '64' ], environ=environ, timeout_seconds=45 * 60, use_workspace=True) else: environ['PYTHON'] = self.py_version environ['SKIP_PIP_INSTALL'] = 'TRUE' return create_jobspec( self.name, ['tools/run_tests/artifacts/build_artifact_python.sh'], environ=environ, timeout_seconds=60 * 60 * 2, use_workspace=True) def __str__(self): return self.name class RubyArtifact: """Builds ruby native gem.""" def __init__(self, platform, arch): self.name = 'ruby_native_gem_%s_%s' % (platform, arch) self.platform = platform self.arch = arch self.labels = ['artifact', 'ruby', platform, arch] def pre_build_jobspecs(self): return [] def build_jobspec(self): # Ruby build uses docker internally and docker cannot be nested. # We are using a custom workspace instead. return create_jobspec( self.name, ['tools/run_tests/artifacts/build_artifact_ruby.sh'], use_workspace=True, timeout_seconds=45 * 60) class CSharpExtArtifact: """Builds C# native extension library""" def __init__(self, platform, arch): self.name = 'csharp_ext_%s_%s' % (platform, arch) self.platform = platform self.arch = arch self.labels = ['artifact', 'csharp', platform, arch] def pre_build_jobspecs(self): return [] def build_jobspec(self): if self.platform == 'windows': cmake_arch_option = 'Win32' if self.arch == 'x86' else self.arch return create_jobspec( self.name, [ 'tools\\run_tests\\artifacts\\build_artifact_csharp.bat', cmake_arch_option ], use_workspace=True) else: environ = { 'CONFIG': 'opt', 'EMBED_OPENSSL': 'true', 'EMBED_ZLIB': 'true', 'CFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE', 'CXXFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE', 'LDFLAGS': '' } if self.platform == 'linux': return create_docker_jobspec( self.name, 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch, 'tools/run_tests/artifacts/build_artifact_csharp.sh', environ=environ) else: archflag = _ARCH_FLAG_MAP[self.arch] environ['CFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG) environ['CXXFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG) environ['LDFLAGS'] += ' %s' % archflag return create_jobspec( self.name, ['tools/run_tests/artifacts/build_artifact_csharp.sh'], environ=environ, use_workspace=True) def __str__(self): return self.name class PHPArtifact: """Builds PHP PECL package""" def __init__(self, platform, arch): self.name = 'php_pecl_package_{0}_{1}'.format(platform, arch) self.platform = platform self.arch = arch self.labels = ['artifact', 'php', platform, arch] def pre_build_jobspecs(self): return [] def build_jobspec(self): if self.platform == 'linux': return create_docker_jobspec( self.name, 'tools/dockerfile/grpc_artifact_linux_{}'.format( self.arch), 'tools/run_tests/artifacts/build_artifact_php.sh') else: return create_jobspec( self.name, ['tools/run_tests/artifacts/build_artifact_php.sh'], use_workspace=True) class ProtocArtifact: """Builds protoc and protoc-plugin artifacts""" def __init__(self, platform, arch): self.name = 'protoc_%s_%s' % (platform, arch) self.platform = platform self.arch = arch self.labels = ['artifact', 'protoc', platform, arch] def pre_build_jobspecs(self): return [] def build_jobspec(self): if self.platform != 'windows': cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch] ldflags = '%s' % _ARCH_FLAG_MAP[self.arch] if self.platform != 'macos': ldflags += ' -static-libgcc -static-libstdc++ -s' environ = { 'CONFIG': 'opt', 'CXXFLAGS': cxxflags, 'LDFLAGS': ldflags, 'PROTOBUF_LDFLAGS_EXTRA': ldflags } if self.platform == 'linux': return create_docker_jobspec( self.name, 'tools/dockerfile/grpc_artifact_protoc', 'tools/run_tests/artifacts/build_artifact_protoc.sh', environ=environ) else: environ[ 'CXXFLAGS'] += ' -std=c++11 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG return create_jobspec( self.name, ['tools/run_tests/artifacts/build_artifact_protoc.sh'], environ=environ, timeout_seconds=60 * 60, use_workspace=True) else: generator = 'Visual Studio 14 2015 Win64' if self.arch == 'x64' else 'Visual Studio 14 2015' return create_jobspec( self.name, ['tools\\run_tests\\artifacts\\build_artifact_protoc.bat'], environ={'generator': generator}, use_workspace=True) def __str__(self): return self.name def targets(): """Gets list of supported targets""" return ([ Cls(platform, arch) for Cls in (CSharpExtArtifact, ProtocArtifact) for platform in ('linux', 'macos', 'windows') for arch in ('x86', 'x64') ] + [ PythonArtifact('linux', 'x86', 'cp27-cp27m'), PythonArtifact('linux', 'x86', 'cp27-cp27mu'), PythonArtifact('linux', 'x86', 'cp34-cp34m'), PythonArtifact('linux', 'x86', 'cp35-cp35m'), PythonArtifact('linux', 'x86', 'cp36-cp36m'), PythonArtifact('linux_extra', 'armv7', '2.7'), PythonArtifact('linux_extra', 'armv7', '3.4'), PythonArtifact('linux_extra', 'armv7', '3.5'), PythonArtifact('linux_extra', 'armv7', '3.6'), PythonArtifact('linux_extra', 'armv6', '2.7'), PythonArtifact('linux_extra', 'armv6', '3.4'), PythonArtifact('linux_extra', 'armv6', '3.5'), PythonArtifact('linux_extra', 'armv6', '3.6'), PythonArtifact('linux', 'x64', 'cp27-cp27m'), PythonArtifact('linux', 'x64', 'cp27-cp27mu'), PythonArtifact('linux', 'x64', 'cp34-cp34m'), PythonArtifact('linux', 'x64', 'cp35-cp35m'), PythonArtifact('linux', 'x64', 'cp36-cp36m'), PythonArtifact('macos', 'x64', 'python2.7'), PythonArtifact('macos', 'x64', 'python3.4'), PythonArtifact('macos', 'x64', 'python3.5'), PythonArtifact('macos', 'x64', 'python3.6'), PythonArtifact('windows', 'x86', 'Python27_32bits'), PythonArtifact('windows', 'x86', 'Python34_32bits'), PythonArtifact('windows', 'x86', 'Python35_32bits'), PythonArtifact('windows', 'x86', 'Python36_32bits'), PythonArtifact('windows', 'x64', 'Python27'), PythonArtifact('windows', 'x64', 'Python34'), PythonArtifact('windows', 'x64', 'Python35'), PythonArtifact('windows', 'x64', 'Python36'), RubyArtifact('linux', 'x64'), RubyArtifact('macos', 'x64'), PHPArtifact('linux', 'x64'), PHPArtifact('macos', 'x64') ])
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 7800, 30700, 11462, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 10701, 402, 4545, 370, 1900, 27990, 1041, 199, 199, 646, 747, 14, 515, 199, 646, 2196, 199, 646, 1059, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24893, 1333, 199, 646, 2366, 63, 1208, 14, 2423, 409, 465, 3906, 409, 421, 199, 318, 1218, 63, 9991, 63, 6920, 733, 8, 354, 12, 2079, 12424, 493, 63, 694, 12, 2079, 5218, 63, 1531, 12, 2079, 6160, 10324, 2079, 27510, 63, 10937, 29, 16, 12, 2079, 2653, 63, 10937, 29, 16, 12, 2079, 2653, 63, 4515, 29, 1216, 627, 5212, 12, 2079, 12424, 63, 1095, 63, 1569, 29, 403, 12, 2079, 2402, 63, 9991, 63, 589, 29, 403, 12, 2079, 3376, 63, 3742, 29, 797, 304, 272, 408, 10607, 9643, 733, 367, 282, 2120, 3879, 1334, 12424, 1041, 272, 6160, 275, 6160, 14, 1574, 342, 272, 6160, 459, 9390, 63, 10761, 418, 275, 5218, 63, 1531, 272, 6160, 459, 2294, 41, 18164, 51, 63, 1877, 418, 275, 283, 30129, 3149, 83, 7, 450, 536, 339, 12424, 63, 589, 275, 942, 272, 367, 1022, 12, 373, 315, 6160, 14, 1744, 837, 267, 12424, 63, 589, 847, 11573, 69, 297, 1543, 83, 2458, 83, 7, 450, 334, 75, 12, 373, 1874, 272, 12424, 63, 1813, 275, 469, 267, 283, 29953, 3817, 63, 3022, 356, 12424, 493, 63, 694, 12, 267, 283, 29953, 63, 9390, 63, 10484, 356, 283, 2537, 15, 1065, 63, 2219, 15, 9991, 794, 15, 9991, 63, 1065, 14, 609, 297, 267, 283, 8414, 63, 3022, 356, 283, 30129, 7, 272, 789, 339, 340, 12424, 63, 1095, 63, 1569, 365, 440, 488, 26, 267, 12424, 63, 1813, 459, 29953, 63, 5825, 63, 9438, 418, 275, 12424, 63, 1095, 63, 1569, 272, 340, 2402, 63, 9991, 63, 589, 365, 440, 488, 26, 267, 12424, 63, 1813, 459, 18555, 63, 29953, 63, 13990, 418, 275, 2402, 63, 9991, 63, 589, 272, 9643, 733, 275, 3906, 409, 14, 6694, 5307, 8, 267, 21206, 2968, 2537, 15, 1065, 63, 2219, 15, 9991, 794, 15, 1506, 63, 460, 63, 1065, 63, 9991, 14, 609, 418, 435, 267, 12424, 63, 589, 12, 267, 6160, 29, 9991, 63, 1813, 12, 267, 3974, 354, 534, 1506, 63, 16154, 4111, 83, 7, 450, 334, 354, 395, 267, 2653, 63, 4515, 29, 2593, 63, 4515, 12, 267, 27510, 63, 10937, 29, 14163, 415, 63, 10937, 12, 267, 2653, 63, 10937, 29, 2593, 63, 10937, 12, 267, 3376, 63, 3742, 29, 3832, 63, 3742, 9, 272, 372, 9643, 733, 421, 199, 318, 1218, 63, 6920, 733, 8, 354, 12, 673, 21206, 12, 673, 6160, 10324, 673, 5218, 29, 797, 12, 673, 27510, 63, 10937, 29, 16, 12, 673, 2653, 63, 10937, 29, 16, 12, 673, 2653, 63, 4515, 29, 1216, 627, 5212, 12, 673, 675, 63, 13249, 29, 797, 12, 673, 5033, 63, 6336, 29, 17, 14, 16, 12, 673, 3376, 63, 3742, 29, 797, 304, 272, 408, 10607, 9643, 733, 1041, 272, 6160, 275, 6160, 14, 1574, 342, 272, 340, 675, 63, 13249, 26, 267, 6160, 459, 8406, 11658, 63, 2339, 418, 275, 283, 13249, 4970, 83, 7, 450, 536, 267, 6160, 459, 2294, 41, 18164, 51, 63, 1877, 418, 275, 747, 14, 515, 14, 904, 24893, 297, 283, 30129, 297, 536, 9, 267, 21206, 275, 788, 16408, 297, 283, 2537, 15, 1065, 63, 2219, 15, 30129, 15, 1065, 63, 262, 63, 13249, 14, 609, 7, 2116, 1622, 435, 21206, 272, 587, 26, 267, 6160, 459, 2294, 41, 18164, 51, 63, 1877, 418, 275, 747, 14, 515, 14, 904, 360, 30129, 297, 536, 9, 339, 9643, 733, 275, 3906, 409, 14, 6694, 5307, 8, 267, 21206, 29, 15612, 12, 267, 6160, 29, 2314, 12, 267, 3974, 354, 534, 1506, 63, 16154, 4111, 83, 7, 450, 334, 354, 395, 267, 2653, 63, 4515, 29, 2593, 63, 4515, 12, 267, 27510, 63, 10937, 29, 14163, 415, 63, 10937, 12, 267, 2653, 63, 10937, 29, 2593, 63, 10937, 12, 267, 5218, 29, 5641, 12, 267, 5033, 63, 6336, 29, 3541, 63, 6336, 12, 267, 3376, 63, 3742, 29, 3832, 63, 3742, 9, 272, 372, 9643, 733, 421, 199, 63, 9410, 3100, 63, 29720, 63, 3719, 275, 2475, 77, 28546, 13, 1023, 13, 827, 29, 709, 14, 23, 7, 199, 199, 63, 7762, 63, 3719, 63, 5443, 275, 791, 88, 1184, 356, 2475, 77, 708, 297, 283, 88, 772, 356, 2475, 77, 772, 936, 421, 199, 533, 2018, 1596, 10048, 26, 272, 408, 27856, 2018, 27990, 1041, 339, 347, 636, 826, 721, 277, 12, 4298, 12, 3819, 12, 1134, 63, 1023, 304, 267, 291, 14, 354, 275, 283, 1548, 4970, 83, 4970, 83, 4970, 83, 7, 450, 334, 3246, 12, 3819, 12, 1134, 63, 1023, 9, 267, 291, 14, 3246, 275, 4298, 267, 291, 14, 1047, 275, 3819, 267, 291, 14, 3512, 275, 788, 16154, 297, 283, 1548, 297, 4298, 12, 3819, 12, 1134, 63, 1023, 61, 267, 291, 14, 647, 63, 1023, 275, 1134, 63, 1023, 339, 347, 876, 63, 1506, 63, 6920, 733, 83, 8, 277, 304, 267, 372, 942, 339, 347, 1900, 63, 6920, 733, 8, 277, 304, 267, 6160, 275, 1052, 267, 340, 291, 14, 3246, 508, 283, 5135, 63, 2911, 356, 288, 327, 820, 20222, 605, 651, 19835, 1900, 288, 6160, 459, 11720, 418, 275, 1994, 2647, 15 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 7800, 30700, 11462, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 10701, 402, 4545, 370, 1900, 27990, 1041, 199, 199, 646, 747, 14, 515, 199, 646, 2196, 199, 646, 1059, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24893, 1333, 199, 646, 2366, 63, 1208, 14, 2423, 409, 465, 3906, 409, 421, 199, 318, 1218, 63, 9991, 63, 6920, 733, 8, 354, 12, 2079, 12424, 493, 63, 694, 12, 2079, 5218, 63, 1531, 12, 2079, 6160, 10324, 2079, 27510, 63, 10937, 29, 16, 12, 2079, 2653, 63, 10937, 29, 16, 12, 2079, 2653, 63, 4515, 29, 1216, 627, 5212, 12, 2079, 12424, 63, 1095, 63, 1569, 29, 403, 12, 2079, 2402, 63, 9991, 63, 589, 29, 403, 12, 2079, 3376, 63, 3742, 29, 797, 304, 272, 408, 10607, 9643, 733, 367, 282, 2120, 3879, 1334, 12424, 1041, 272, 6160, 275, 6160, 14, 1574, 342, 272, 6160, 459, 9390, 63, 10761, 418, 275, 5218, 63, 1531, 272, 6160, 459, 2294, 41, 18164, 51, 63, 1877, 418, 275, 283, 30129, 3149, 83, 7, 450, 536, 339, 12424, 63, 589, 275, 942, 272, 367, 1022, 12, 373, 315, 6160, 14, 1744, 837, 267, 12424, 63, 589, 847, 11573, 69, 297, 1543, 83, 2458, 83, 7, 450, 334, 75, 12, 373, 1874, 272, 12424, 63, 1813, 275, 469, 267, 283, 29953, 3817, 63, 3022, 356, 12424, 493, 63, 694, 12, 267, 283, 29953, 63, 9390, 63, 10484, 356, 283, 2537, 15, 1065, 63, 2219, 15, 9991, 794, 15, 9991, 63, 1065, 14, 609, 297, 267, 283, 8414, 63, 3022, 356, 283, 30129, 7, 272, 789, 339, 340, 12424, 63, 1095, 63, 1569, 365, 440, 488, 26, 267, 12424, 63, 1813, 459, 29953, 63, 5825, 63, 9438, 418, 275, 12424, 63, 1095, 63, 1569, 272, 340, 2402, 63, 9991, 63, 589, 365, 440, 488, 26, 267, 12424, 63, 1813, 459, 18555, 63, 29953, 63, 13990, 418, 275, 2402, 63, 9991, 63, 589, 272, 9643, 733, 275, 3906, 409, 14, 6694, 5307, 8, 267, 21206, 2968, 2537, 15, 1065, 63, 2219, 15, 9991, 794, 15, 1506, 63, 460, 63, 1065, 63, 9991, 14, 609, 418, 435, 267, 12424, 63, 589, 12, 267, 6160, 29, 9991, 63, 1813, 12, 267, 3974, 354, 534, 1506, 63, 16154, 4111, 83, 7, 450, 334, 354, 395, 267, 2653, 63, 4515, 29, 2593, 63, 4515, 12, 267, 27510, 63, 10937, 29, 14163, 415, 63, 10937, 12, 267, 2653, 63, 10937, 29, 2593, 63, 10937, 12, 267, 3376, 63, 3742, 29, 3832, 63, 3742, 9, 272, 372, 9643, 733, 421, 199, 318, 1218, 63, 6920, 733, 8, 354, 12, 673, 21206, 12, 673, 6160, 10324, 673, 5218, 29, 797, 12, 673, 27510, 63, 10937, 29, 16, 12, 673, 2653, 63, 10937, 29, 16, 12, 673, 2653, 63, 4515, 29, 1216, 627, 5212, 12, 673, 675, 63, 13249, 29, 797, 12, 673, 5033, 63, 6336, 29, 17, 14, 16, 12, 673, 3376, 63, 3742, 29, 797, 304, 272, 408, 10607, 9643, 733, 1041, 272, 6160, 275, 6160, 14, 1574, 342, 272, 340, 675, 63, 13249, 26, 267, 6160, 459, 8406, 11658, 63, 2339, 418, 275, 283, 13249, 4970, 83, 7, 450, 536, 267, 6160, 459, 2294, 41, 18164, 51, 63, 1877, 418, 275, 747, 14, 515, 14, 904, 24893, 297, 283, 30129, 297, 536, 9, 267, 21206, 275, 788, 16408, 297, 283, 2537, 15, 1065, 63, 2219, 15, 30129, 15, 1065, 63, 262, 63, 13249, 14, 609, 7, 2116, 1622, 435, 21206, 272, 587, 26, 267, 6160, 459, 2294, 41, 18164, 51, 63, 1877, 418, 275, 747, 14, 515, 14, 904, 360, 30129, 297, 536, 9, 339, 9643, 733, 275, 3906, 409, 14, 6694, 5307, 8, 267, 21206, 29, 15612, 12, 267, 6160, 29, 2314, 12, 267, 3974, 354, 534, 1506, 63, 16154, 4111, 83, 7, 450, 334, 354, 395, 267, 2653, 63, 4515, 29, 2593, 63, 4515, 12, 267, 27510, 63, 10937, 29, 14163, 415, 63, 10937, 12, 267, 2653, 63, 10937, 29, 2593, 63, 10937, 12, 267, 5218, 29, 5641, 12, 267, 5033, 63, 6336, 29, 3541, 63, 6336, 12, 267, 3376, 63, 3742, 29, 3832, 63, 3742, 9, 272, 372, 9643, 733, 421, 199, 63, 9410, 3100, 63, 29720, 63, 3719, 275, 2475, 77, 28546, 13, 1023, 13, 827, 29, 709, 14, 23, 7, 199, 199, 63, 7762, 63, 3719, 63, 5443, 275, 791, 88, 1184, 356, 2475, 77, 708, 297, 283, 88, 772, 356, 2475, 77, 772, 936, 421, 199, 533, 2018, 1596, 10048, 26, 272, 408, 27856, 2018, 27990, 1041, 339, 347, 636, 826, 721, 277, 12, 4298, 12, 3819, 12, 1134, 63, 1023, 304, 267, 291, 14, 354, 275, 283, 1548, 4970, 83, 4970, 83, 4970, 83, 7, 450, 334, 3246, 12, 3819, 12, 1134, 63, 1023, 9, 267, 291, 14, 3246, 275, 4298, 267, 291, 14, 1047, 275, 3819, 267, 291, 14, 3512, 275, 788, 16154, 297, 283, 1548, 297, 4298, 12, 3819, 12, 1134, 63, 1023, 61, 267, 291, 14, 647, 63, 1023, 275, 1134, 63, 1023, 339, 347, 876, 63, 1506, 63, 6920, 733, 83, 8, 277, 304, 267, 372, 942, 339, 347, 1900, 63, 6920, 733, 8, 277, 304, 267, 6160, 275, 1052, 267, 340, 291, 14, 3246, 508, 283, 5135, 63, 2911, 356, 288, 327, 820, 20222, 605, 651, 19835, 1900, 288, 6160, 459, 11720, 418, 275, 1994, 2647, 15, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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, re import HTMLParser import xbmcaddon import json import traceback import os import sys import cookielib from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP, Tag,NavigableString try: from lxmlERRRORRRR import etree print("running with lxml.etree") except ImportError: try: # Python 2.5 import xml.etree.ElementTree as etree print("running with ElementTree on Python 2.5+") except ImportError: try: # normal cElementTree install import cElementTree as etree print("running with cElementTree") except ImportError: try: # normal ElementTree install import elementtree.ElementTree as etree print("running with ElementTree") except ImportError: print("Failed to import ElementTree from any known place") import json __addon__ = xbmcaddon.Addon() __addonname__ = __addon__.getAddonInfo('name') __icon__ = __addon__.getAddonInfo('icon') addon_id = 'plugin.video.shahidmbcnet' selfAddon = xbmcaddon.Addon(id=addon_id) addonPath = xbmcaddon.Addon().getAddonInfo("path") addonversion =xbmcaddon.Addon().getAddonInfo("version") addonArt = os.path.join(addonPath,'resources/images') communityStreamPath = os.path.join(addonPath,'resources') communityStreamPath =os.path.join(communityStreamPath,'community') profile_path = xbmc.translatePath(selfAddon.getAddonInfo('profile')) ShahidCOOKIEFILE = communityStreamPath+'/ShahidVodCookie.lwp' mainurl='http://shahid.mbc.net' apikey='AIzaSyCl5mHLlE0mwsyG4uvNHu5k1Ej1LQ_3RO4' def getMainUrl(): rMain=mainurl #check setting and see if we have proxy define, ifso, use that isProxyEnabled=defaultCDN=selfAddon.getSetting( "isProxyEnabled" ) proxyAddress=defaultCDN=selfAddon.getSetting( "proxyName" ) applySSL=True if isProxyEnabled:#if its not None #print 'isProxyEnabled',isProxyEnabled,proxyAddress if isProxyEnabled=="true": #print 'its enabled' applySSL=False rMain=proxyAddress #else: #print 'Proxy not enable' if applySSL: return rMain.replace('http:','https:') else: return rMain#.replace('http:','https:') VIEW_MODES = { 'thumbnail': { 'skin.confluence': 500, 'skin.aeon.nox': 551, 'skin.confluence-vertical': 500, 'skin.jx720': 52, 'skin.pm3-hd': 53, 'skin.rapier': 50, 'skin.simplicity': 500, 'skin.slik': 53, 'skin.touched': 500, 'skin.transparency': 53, 'skin.xeebo': 55, }, } def get_view_mode_id( view_mode): default_view_mode=selfAddon.getSetting( "usethisviewmode" ) if default_view_mode=="": view_mode_ids = VIEW_MODES.get(view_mode.lower()) if view_mode_ids: return view_mode_ids.get(xbmc.getSkinDir()) else: return int(default_view_mode) return None def addLink(name,url,iconimage): ok=True liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) liz.setInfo( type="Video", infoLabels={ "Title": name } ) ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz) return ok def Colored(text = '', colorid = '', isBold = False): if colorid == 'one': color = 'FF11b500' elif colorid == 'two': color = 'FFe37101' elif colorid == 'bold': return '[B]' + text + '[/B]' else: color = colorid if isBold == True: text = '[B]' + text + '[/B]' return '[COLOR ' + color + ']' + text + '[/COLOR]' def addDir(name,url,mode,iconimage ,showContext=False,isItFolder=True,pageNumber="", isHTML=True,addIconForPlaylist=False, AddRemoveMyChannels=None, SelectDefaultSource=None, hideChannel=None, BySource=None): # print name # name=name.decode('utf-8','replace') if isHTML: h = HTMLParser.HTMLParser() name= h.unescape(name).decode("utf-8") rname= name.encode("utf-8") else: #h = HTMLParser.HTMLParser() #name =h.unescape(name).decode("utf-8") rname= name.encode("utf-8") # url= url.encode("utf-8") # url= url.encode('ascii','ignore') #print rname #print iconimage u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(rname) if BySource: u+="&sourceFilter="+urllib.quote_plus(BySource) if len(pageNumber): u+="&pagenum="+pageNumber if addIconForPlaylist: u+="&addIconForPlaylist=yes" ok=True # print iconimage liz=xbmcgui.ListItem(rname, iconImage="DefaultFolder.png", thumbnailImage=iconimage) #liz.setInfo( type="Video", infoLabels={ "Title": name } ) if showContext==True: cmd1 = "XBMC.RunPlugin(%s&cdnType=%s)" % (u, "l3") cmd2 = "XBMC.RunPlugin(%s&cdnType=%s)" % (u, "xdn") cmd3 = "XBMC.RunPlugin(%s&cdnType=%s)" % (u, "ak") liz.addContextMenuItems([('Play using L3 Cdn',cmd1),('Play using XDN Cdn',cmd2),('Play using AK Cdn',cmd3)]) context_menu=[] if not AddRemoveMyChannels==None: if AddRemoveMyChannels: cmd1 = "XBMC.RunPlugin(%s&AddRemoveMyChannels=add)" % (u) context_menu.append(('Add to My Channels',cmd1)) else: cmd1 = "XBMC.RunPlugin(%s&AddRemoveMyChannels=remove)" % (u) context_menu.append(('Remove from My Channels',cmd1)) if SelectDefaultSource: #print 'select defauly' cmd2 = "XBMC.RunPlugin(%s&selectDefaultSource=yes)" % (u) context_menu.append(('Select default source',cmd2)) if not hideChannel==None: if hideChannel: cmd3 = "XBMC.RunPlugin(%s&HideChannel=yes)" % (u) context_menu.append(('Hide this Channel',cmd3)) else: cmd3 = "XBMC.RunPlugin(%s&HideChannel=no)" % (u) context_menu.append(('Unhide this Channel',cmd3)) if len(context_menu)>0: liz.addContextMenuItems(context_menu,replaceItems=False) # if selfAddon.getSetting( "addToFavMode" )=="true": # liz.addContextMenuItems(context_menu,replaceItems=False) # else: # liz.addContextMenuItems(context_menu,replaceItems=True) ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isItFolder) return ok def get_params(): param=[] paramstring=sys.argv[2] if len(paramstring)>=2: params=sys.argv[2] cleanedparams=params.replace('?','') if (params[len(params)-1]=='/'): params=params[0:len(params)-2] pairsofparams=cleanedparams.split('&') param={} for i in range(len(pairsofparams)): splitparams={} splitparams=pairsofparams[i].split('=') if (len(splitparams))==2: param[splitparams[0]]=splitparams[1] return param def Addtypes(): addDir('Shahid Live' ,'CCats' ,14,addonArt+'/Network-1-icon.png') #2 is series=3 are links addDir('Shahid Vod by Channels' ,getMainUrl()+'/ar/channel-browser.html' ,2,addonArt+'/channels.png') #links #2 channels,3 series,4 video entry, 5 play addDir('Shahid Vod by Series' ,getMainUrl()+'/ar/series-browser.html' ,6,addonArt+'/serial.png') ##stopping it as currently its Drmd! ## addDir('Shahid Vod Films' ,getMainUrl()+'/ar/movies.html' ,27,addonArt+'/serial.png') #addDir('Streams' ,'streams' ,9,addonArt+'/stream.png') addDir('Shahid Youtube' ,'http://gdata.youtube.com/feeds/api/users/aljadeedonline' ,18,addonArt+'/youtube.png') addDir('Download Files' ,'cRefresh' ,17,addonArt+'/download-icon.png',isItFolder=False) addDir('Settings' ,'Settings' ,8,addonArt+'/setting.png',isItFolder=False) ## # addDir('Livetv.tn Login' ,'Livetv' ,24,addonArt+'/setting.png',isItFolder=False) ## return def AddShahidVodMovietypes(): addDir('Best Of Drama' ,getMainUrl()+'/ar/movies/content/04-param-.sort-popular.pageNumber-1.html' ,28,addonArt+'/channels.png') #links #2 channels,3 series,4 video entry, 5 play addDir('Best Of Commedy' ,getMainUrl()+'/ar/movies/content/00-param-.sort-popular.pageNumber-1.html' ,29,addonArt+'/channels.png') #links #2 channels,3 series,4 video entry, 5 play addDir('Best Of Classics' ,getMainUrl()+'/ar/movies/content/01-param-.sort-popular.pageNumber-1.html' ,30,addonArt+'/channels.png') #links #2 channels,3 series,4 video entry, 5 play addDir('Latest Movies' ,getMainUrl()+'/ar/movies/content/0~listing~-param-.ptype-.Id-0.sort-latest.pageNumber-1.html' ,31,addonArt+'/channels.png') #links #2 channels,3 series,4 video entry, 5 play # addDir('Livetv.tn Login' ,'Livetv' ,24,addonArt+'/setting.png',isItFolder=False) ## return def AddShahidMovies(url): link=getUrl(url); patt='<img.*alt="(.*?)" src="(.*?)".*\s?.*\s.*\s*.*\/movie\/([0-9]*)' match =re.findall(patt, link, re.UNICODE) totalEnteries=len(match) for cname in match: finalName=cname[0]; img=cname[1] addDir(finalName ,cname[2] ,32,img,showContext=False,isItFolder=False) ''' print 'Current pg',pageNumber,Fromurl if totalEnteries>=24: match =re.findall('<li class="arrowrgt"><a.*?this, \'(.*?(relatedEpisodeListingDynamic).*?)\'', link, re.UNICODE) if len(match)>0 or mode==7 : if not pageNumber=="": pageNumber=str(int(pageNumber)+1);#parseInt(1)+1; else: pageNumber="1"; if mode==7: newurl=(Fromurl.split('pageNumber')[0]+'pageNumber-%s.html')%pageNumber else: newurl=getMainUrl()+match[0][0]+'.sort-number:DESC.pageNumber-%s.html'%pageNumber; print 'next page url',newurl addDir('Next Page' ,newurl ,7,addonArt+'/next.png', False,pageNumber=pageNumber) #name,url,mode,icon ''' def AddYoutubeLanding(url): if not url.lower().startswith('http'): if url=='LOCAL': filename=selfAddon.getSetting( "localyoutubexmlpath" ) else: filename=url #print 'filename',filename if len(filename)>0: data = open(filename.decode('utf-8'), "r").read() #print data directories=getETreeFromString(data) else: dialog = xbmcgui.Dialog() ok = dialog.ok('XBMC', 'File not defined') return else: directories=getETreeFromUrl(url) for dir in directories.findall('dir'): name = dir.find('name').text link= dir.find('link') if not link==None: link=link.text videouser= dir.find('youtubeuser') if not videouser==None: videouser=videouser.text channelID= dir.find('channelid') if not channelID==None: channelID=channelID.text thumbnail= dir.find('thumbnail') if not thumbnail==None: thumbnail=thumbnail.text #print name,link thumbnail= dir.find('thumbnail').text if thumbnail==None: thumbnail='' #print 'thumbnail',thumbnail type = dir.find('type') if type==None: #check the link and decide if not link==None: if link.endswith('playlists'): type='playlist' elif link.endswith('uploads'): type='videos' elif 'watch?v' in link: type='video' else: type='dir' else: type='dir' else: type=type.text #print 'channelID',channelID if type=='playlist' or type=='videos': if channelID==None or len(channelID)==0: if videouser==None: #get it from the link link=link.split('/')[-2] else: link=videouser #print 'link for Channelid',link link=getChannelIdByUserName(link)#passusername else: link=channelID icon=addonArt+'/video.png' if (not thumbnail==None) and len(thumbnail)>0: icon=thumbnail #print 'icon',icon if type=='playlist': addDir(name ,link ,22,addonArt+'/playlist.png',isHTML=False) elif type=='videos': addDir(name ,link ,20,icon,isHTML=False) elif type=='video': addDir(name ,link ,21,thumbnail,isItFolder=False, isHTML=False) #name,url,mode,icon else: addDir(name ,link ,19,thumbnail,isItFolder=True, isHTML=False) #name,url,mode,icon def checkAndRefresh(): try: import time lastUpdate=selfAddon.getSetting( "lastupdate" ) do_update=False now_date=time.strftime("%d/%m/%Y") if lastUpdate==None or lastUpdate=="": do_update=True else: #print 'lastUpdate',lastUpdate,now_date if not now_date==lastUpdate: do_update=True if selfAddon.getSetting( "stopAutoUpdate" )=="true": do_update=False selfAddon.setSetting( id="lastupdate" ,value=now_date) if do_update: RefreshResources(True) except: pass def RefreshResources(auto=False, fNameOnly=None): # print Fromurl pDialog = xbmcgui.DialogProgress() if auto: ret = pDialog.create('XBMC', 'Daily Auto loading Fetching resources...') else: ret = pDialog.create('XBMC', 'Fetching resources...') baseUrlForDownload='https://raw.githubusercontent.com/Shani-08/ShaniXBMCWork/master/plugin.video.shahidmbcnet/resources/community/' Fromurl=baseUrlForDownload+'Resources.xml' req = urllib2.Request(Fromurl) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) data=response.read() response.close() #data='<resources><file fname="Categories.xml"/><file fname="palestinecoolUrls.xml" url="http://goo.gl/yNlwCM"/></resources>' pDialog.update(20, 'Importing modules...') soup= BeautifulSOAP(data, convertEntities=BeautifulStoneSoup.XML_ENTITIES) resources=soup('file') fileno=1 totalFile = len(resources) import hashlib for rfile in resources: if pDialog.iscanceled(): return progr = (fileno*80)/totalFile fname = rfile['fname'] if fNameOnly and not fname==fNameOnly: continue remoteUrl=None try: remoteUrl = rfile['url'] except: pass isBase64=False try: isBase64= rfile['base64']=="true" except: pass if remoteUrl: fileToDownload = remoteUrl else: fileToDownload = baseUrlForDownload+fname fileHash=hashlib.md5(fileToDownload+addonversion).hexdigest() lastFileTime=selfAddon.getSetting( "Etagid"+fileHash) if lastFileTime=="": lastFileTime=None resCode=200 #print fileToDownload eTag=None try: req = urllib2.Request(fileToDownload) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') if lastFileTime: req.add_header('If-None-Match',lastFileTime) response = urllib2.urlopen(req) resCode=response.getcode() if resCode<>304: try: eTag=response.info().getheader('Etag') except: pass data=response.read() except Exception as e: s = str(e) if 'Not Modified'.lower() in s.lower(): resCode=304 data='' if len(data)>0: try: if isBase64: import base64 data=base64.b64decode(data) except: print 'Failed..not base64.'+fname pDialog.update(20+progr, 'Failed..not base64.'+fname) data='' if len(data)>0: with open(os.path.join(communityStreamPath, fname), "wb") as filewriter: filewriter.write(data) if eTag: selfAddon.setSetting( id="Etagid"+fileHash ,value=eTag) pDialog.update(20+progr, 'imported ...'+fname) elif resCode==304: pDialog.update(20+progr, 'No Change.. skipping.'+fname) else: pDialog.update(20+progr, 'Failed..zero byte.'+fname) fileno+=1 pDialog.close() dialog = xbmcgui.Dialog() ok = dialog.ok('XBMC', 'Download finished. Close Addon and come back') def removeLoginFile(livePlayer,TeleDunet,showMsg=True): something_done=False try: if livePlayer: something_done=True selfAddon.setSetting( id="lastLivetvWorkingCode" ,value="") COOKIEFILE = communityStreamPath+'/livePlayerLoginCookie.lwp' os.remove(COOKIEFILE) except: pass try: if TeleDunet: if communityStreamPath not in sys.path: sys.path.append(communityStreamPath) #print processor #from importlib import import_module print 'clear cahche' processorObject=import_module('teledunetPlayer') processorObject.clearFileCache() print 'clear cahchesssssssssssssssssssssssssssssssddd' something_done=True COOKIEFILE = communityStreamPath+'/teletdunetPlayerLoginCookie.lwp' os.remove(COOKIEFILE) except: pass if something_done and showMsg: time = 2000 #in miliseconds line1="Session data removed!" xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) def ShowSettings(Fromurl): current_LivePlayerLogin=selfAddon.getSetting( "liveTvLogin" )+selfAddon.getSetting( "liveTvPassword") current_teleDunetLogin=selfAddon.getSetting( "teledunetTvLogin" )+selfAddon.getSetting( "teledunetTvPassword") selfAddon.setSetting( id="clearLogonSettings" ,value="false") selfAddon.openSettings() #print 'after settings' clearLogonSettings=selfAddon.getSetting( "clearLogonSettings" ) after_LivePlayerLogin=selfAddon.getSetting( "liveTvLogin" )+selfAddon.getSetting( "liveTvPassword") after_teleDunetLogin=selfAddon.getSetting( "teledunetTvLogin" )+selfAddon.getSetting( "teledunetTvPassword") removeLoginFile(clearLogonSettings=="true" or not current_LivePlayerLogin==after_LivePlayerLogin, clearLogonSettings=="true" or not current_teleDunetLogin==after_teleDunetLogin ) return def LIVETvLogin(Fromurl): Msg="" try: if communityStreamPath not in sys.path: sys.path.append(communityStreamPath) removeLoginFile(True,False,showMsg=False) processorObject=import_module('livetvPlayer') new_code=processorObject.getLoginCode() if new_code: selfAddon.setSetting( id="liveTvNonPremiumCode" ,value=new_code) Msg="Login successful" else: Msg="Login failed.If login not working then enter the code manually in the settings." except: traceback.print_exc(file=sys.stdout) Msg="Login failed.If login not working then enter the code manually in the settings." dialog = xbmcgui.Dialog() ok = dialog.ok('Livetv Login', Msg) return def AddSeries(Fromurl,pageNumber=""): # print Fromurl req = urllib2.Request(Fromurl) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) link=response.read() response.close() #print Fromurl # print "addshows" # match=re.compile('<param name="URL" value="(.+?)">').findall(link) # match=re.compile('<a href="(.+?)"').findall(link) # match=re.compile('onclick="playChannel\(\'(.*?)\'\);">(.*?)</a>').findall(link) # match =re.findall('onclick="playChannel\(\'(.*?)\'\);">(.*?)</a>', link, re.DOTALL|re.IGNORECASE) # match =re.findall('onclick="playChannel\(\'(.*?)\'\);".?>(.*?)</a>', link, re.DOTALL|re.IGNORECASE) # match =re.findall('<div class=\"post-title\"><a href=\"(.*?)\".*<b>(.*)<\/b><\/a>', link, re.IGNORECASE) # match =re.findall('<img src="(.*?)" alt=".*".+<\/a>\n*.+<div class="post-title"><a href="(.*?)".*<b>(.*)<\/b>', link, re.UNICODE) #regstring='<a href="(.*?)">[\s\t\r\n\f]*.*[\s\t\r\n\f]+.*[\s\t\r\n\f].*<img .*?alt="(.*?)" src="(.*?)"' regstring='<a href="(\/ar\/(show|series).*?)">\s.*\s*.*\s.*alt="(.*)" src="(.*?)" ' match =re.findall(regstring, link) #match=re.compile('<a href="(.*?)"targe.*?<img.*?alt="(.*?)" src="(.*?)"').findall(link) #print Fromurl for cname in match: img=cname[3] #img=mainurl#img.replace(getMainUrl(),mainurl) #print 'img is ',img addDir(cname[2] ,getMainUrl()+cname[0] ,4,img)#name,url,img if mode==6: if not pageNumber=="": pageNumber=str(int(pageNumber)+1);#parseInt(1)+1; else: pageNumber="1"; purl=getMainUrl()+'/ar/series-browser/autoGeneratedContent/seriesBrowserGrid~browse~-param-.sort-latest.pageNumber-%s.html' % pageNumber addDir('Next Page' ,purl ,6,addonArt+'/next.png', False,pageNumber=pageNumber) #name,url,mode,icon # <a href="http://www.zemtv.com/page/2/">&gt;</a></li> # match =re.findall('<a href="(.*)">&gt;<\/a><\/li>', link, re.IGNORECASE) # if len(match)==1: # addDir('Next Page' ,match[0] ,2,'') # print match return def AddEnteries(Fromurl,pageNumber=0): # print Fromurl req = urllib2.Request(Fromurl) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) link=response.read() response.close() # print link # print "addshows" # match=re.compile('<param name="URL" value="(.+?)">').findall(link) # match=re.compile('<a href="(.+?)"').findall(link) # match=re.compile('onclick="playChannel\(\'(.*?)\'\);">(.*?)</a>').findall(link) # match =re.findall('onclick="playChannel\(\'(.*?)\'\);">(.*?)</a>', link, re.DOTALL|re.IGNORECASE) # match =re.findall('onclick="playChannel\(\'(.*?)\'\);".?>(.*?)</a>', link, re.DOTALL|re.IGNORECASE) # match =re.findall('<div class=\"post-title\"><a href=\"(.*?)\".*<b>(.*)<\/b><\/a>', link, re.IGNORECASE) # match =re.findall('<img src="(.*?)" alt=".*".+<\/a>\n*.+<div class="post-title"><a href="(.*?)".*<b>(.*)<\/b>', link, re.UNICODE) # print Fromurl match =re.findall('<a href="(\/ar\/episode.*?)">\s.*\s.*\s.*\s.*\s.*\s.*<img .*?alt="(.*?)" src="(.*?)".*\s.*.*\s.*.*\s.*.*\s.*.*\s.*.*\s.*\s*.*?>(.*?)<\/div>\s*.*?>(.*?)<\/div>', link, re.UNICODE) # print Fromurl #print match #h = HTMLParser.HTMLParser() #print match totalEnteries=len(match) for cname in match: finalName=cname[1]; if len(finalName)>0: finalName+=' ' finalName+=cname[3].replace('<span>','').replace('</span>','') img=cname[2] # img=img.replace(getMainUrl(),'http://shahid.mbc.net.prx.websiteproxy.co.uk') #print 'img is ',img #print 'a1' #if len(finalName)>0: finalName+=u" "; #print 'a2' if len(finalName)>0: finalName+=' ' finalName+=cname[4] #print 'a3' #finalName+=cname[3] #print 'a4' #print cname[2] addDir(finalName ,getMainUrl()+cname[0] ,5,img,showContext=True,isItFolder=False) print 'Current pg',pageNumber,Fromurl if totalEnteries>=24: match =re.findall('<li class="arrowrgt"><a.*?this, \'(.*?(relatedEpisodeListingDynamic).*?)\'', link, re.UNICODE) if len(match)>0 or mode==7 : if not pageNumber=="": pageNumber=str(int(pageNumber)+1);#parseInt(1)+1; else: pageNumber="1"; if mode==7: newurl=(Fromurl.split('pageNumber')[0]+'pageNumber-%s.html')%pageNumber else: newurl=getMainUrl()+match[0][0]+'.sort-number:DESC.pageNumber-%s.html'%pageNumber; print 'next page url',newurl addDir('Next Page' ,newurl ,7,addonArt+'/next.png', False,pageNumber=pageNumber) #name,url,mode,icon # <a href="http://www.zemtv.com/page/2/">&gt;</a></li> #match =re.findall('<link rel=\'next\' href=\'(.*?)\' \/>', link, re.IGNORECASE) #if len(match)==1: # addDir('Next Page' ,match[0] ,3,'') # print match return def AddChannels(liveURL): req = urllib2.Request(liveURL) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) link=response.read() response.close() # print link # match=re.compile('<param name="URL" value="(.+?)">').findall(link) # match=re.compile('<a href="(.+?)"').findall(link) # match=re.compile('onclick="playChannel\(\'(.*?)\'\);">(.*?)</a>').findall(link) # match =re.findall('onclick="playChannel\(\'(.*?)\'\);">(.*?)</a>', link, re.DOTALL|re.IGNORECASE) # match =re.findall('onclick="playChannel\(\'(.*?)\'\);".?>(.*?)</a>', link, re.DOTALL|re.IGNORECASE) # match =re.findall('<div class=\"post-title\"><a href=\"(.*?)\".*<b>(.*)<\/b><\/a>', link, re.IGNORECASE) # match =re.findall('<img src="(.*?)" alt=".*".+<\/a>\n*.+<div class="post-title"><a href="(.*?)".*<b>(.*)<\/b>', link, re.UNICODE) match =re.findall('<div class="subitem".*?id="(.*)">\s*.*\s*<a href="(.*?)".*\s.*\s*<.*src="(.*?)"', link,re.M) #print match #h = HTMLParser.HTMLParser() #print match for cname in match: chName=cname[1].split('/')[-1].split('.htm')[0] img=cname[2] # img=img.replace(getMainUrl(),mainurl) #print chName addDir(chName ,getMainUrl()+cname[1] ,3,img, False,isItFolder=True) #name,url,mode,icon return def AddYoutubeSources(url): addDir('Most Popular' ,'MOSTPOP' ,23,addonArt+'/top.png',isHTML=False) addDir('Most Popular Today' ,'MOSTPOPToday' ,23,addonArt+'/toptday.png',isHTML=False) #addDir('Most Viewed' ,'https://gdata.youtube.com/feeds/api/standardfeeds/most_popular?orderby=viewCount' ,20,addonArt+'/topview.png',isHTML=False) data=getYoutubeSources() addDir('Your Videos' ,'LOCAL' ,19,addonArt+'/yourtube.png',isItFolder=True, isHTML=False) #name,url,mode,icon for stuff in data: addDir(stuff[0] ,stuff[1] ,19,stuff[2],isItFolder=True, isHTML=False) #name,url,mode,icon def getYoutubeSources(): #Ssoup=getSoup('YoutubeSources.xml'); sources=getEtreeFromFile('YoutubeSources.xml'); ret=[] try: for source in sources.findall('source'): isEnabled = source.findtext('enabled').lower() if isEnabled=="true": ret.append([source.findtext('sname'),source.findtext('url'),source.findtext('imageurl')]) except: traceback.print_exc(file=sys.stdout) pass return ret def PlayYoutube(url): youtubecode=url uurl = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % youtubecode xbmc.executebuiltin("xbmc.PlayMedia("+uurl+")") def AddYoutubePlaylists(channelId): #if not username.startswith('https://www.googleapis'): # channelId=getChannelIdByUserName(username)#passusername #else: # channelId=username #channelId=username playlists,next_page=getYouTubePlayList(channelId); for playList in playlists: #print playList addDir(playList[0] ,playList[1] ,23,playList[2],isItFolder=True, isHTML=False) #name,url,mode,icon if next_page: addDir('Next' ,next_page ,22,addonArt+'/next.png',isItFolder=True) #name,url,mode,icon def getYouTubePlayList(channelId): if not channelId.startswith('https://www.googleapis'): u_url='https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=%s&maxResults=25&key=%s'%(channelId,apikey) else: u_url=channelId doc=getJson(u_url) ret=[] for playlist_item in doc['items']: title = playlist_item["snippet"]["title"] id = playlist_item["id"] if not title=='Private video': imgurl='' try: imgurl= playlist_item["snippet"]["thumbnails"]["high"]["url"] except: pass if imgurl=='': try: imgurl= playlist_item["snippet"]["thumbnails"]["default"]["url"] except: pass ret.append([title,id,imgurl]) nextItem=None if 'nextPageToken' in doc: nextItem=doc["nextPageToken"] else: nextItem=None nextUrl=None if nextItem: if not '&pageToken' in u_url: nextUrl=u_url+'&pageToken='+nextItem else: nextUrl=u_url.split('&pageToken=')[0]+'&pageToken='+nextItem return ret,nextUrl; def AddYoutubeVideosByChannelID(channelId,addIconForPlaylist): AddPlayListIcon=True #add all the time #if AddPlayListIcon="yes": # AddPlayListIcon=True #channelId=getChannelIdByUserName(url)#passusername playlist=getUploadPlaylist(channelId) AddYoutubeVideosByPlaylist(playlist,AddPlayListIcon,channelId) def AddYoutubeVideosByPlaylist(playListId,AddPlayListIcon=False, channelid=None): #print 'AddYoutube',url if playListId=='MOSTPOP': videos,next_page=getYoutubeVideosPopular(); elif playListId=='MOSTPOPToday': videos,next_page=getYoutubeVideosPopular(True); else: videos,next_page=getYoutubeVideosByPlaylist(playListId); if AddPlayListIcon: addDir('Playlists' ,channelid ,22,addonArt+'/playlist.png',isHTML=False) for video in videos: #print chName #print video addDir(video[0] ,video[1] ,21,video[2],isItFolder=False, isHTML=False) #name,url,mode,icon if next_page: addDir('Next' ,next_page ,23,addonArt+'/next.png',isItFolder=True) #name,url,mode,icon def getFirstElement(elements,attrib, val): for el in elements: #print el.attrib[attrib] if el.attrib[attrib]==val: #print 'found next' return el return None def getJson(url): req = urllib2.Request(url) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) #link=response.read() #response.close() decoded = json.load(response) return decoded def getChannelIdByUserName(username): u_url='https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=%s&key=%s'%(username,apikey) channelData=getJson(u_url) return channelData['items'][0]['id'] def getUploadPlaylist(mainChannel): u_url='https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=%s&key=%s'%(mainChannel,apikey) doc=getJson(u_url) upload_feed=doc['items'][0]['contentDetails']['relatedPlaylists']['uploads'] return upload_feed def getYoutubeVideosByPlaylist(playlistId): if playlistId.startswith('https://www'): #nextpage u_url=playlistId else: u_url='https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId=%s&key=%s'%(playlistId,apikey) videos=getJson(u_url) return prepareYoutubeVideoItems(videos,u_url) def getYoutubeVideosPopular(today=False): if not today: u_url='https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&order=viewCount&type=video&key=%s'%(apikey) else: import datetime t=datetime.datetime.utcnow()-datetime.timedelta(days=1) yesterday=t.strftime("%Y-%m-%dT%H:%M:%SZ") u_url='https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&order=viewCount&type=video&key=%s&publishedAfter=%s'%(apikey,yesterday) videos=getJson(u_url) return prepareYoutubeVideoItems(videos,u_url) def prepareYoutubeVideoItems(videos,urlUsed): #print 'urlUsed',urlUsed if 'nextPageToken' in videos: nextItem=videos["nextPageToken"] else: nextItem=None ret=[] for playlist_item in videos["items"]: title = playlist_item["snippet"]["title"] #print 'urlUsed',urlUsed if not 'search?part=snippet' in urlUsed: video_id = playlist_item["snippet"]["resourceId"]["videoId"] else: video_id =playlist_item["id"]["videoId"] if not title=='Private video': imgurl='' try: imgurl= playlist_item["snippet"]["thumbnails"]["high"]["url"] except: pass if imgurl=='': try: imgurl= playlist_item["snippet"]["thumbnails"]["default"]["url"] except: pass #print "%s (%s)" % (title, video_id) ret.append([title,video_id,imgurl]) nextUrl=None if nextItem: if not '&pageToken' in urlUsed: nextUrl=urlUsed+'&pageToken='+nextItem else: nextUrl=urlUsed.split('&pageToken=')[0]+'&pageToken='+nextItem return ret,nextUrl; def AddStreams(): match=getStreams(); #print 'match',match match=sorted(match,key=lambda x:x[0].lower()) cstream='<channels>' infostream='<streamingInfos>' #print 'match',match for cname in match: if 'hdarabic' in cname[1]: chName=Colored(cname[0],'one',False); chUrl = cname[1] if not 'http:' in cname[2]: imageUrl = 'http://www.hdarabic.com/./images/'+cname[2]+'.jpg' else: imageUrl=cname[2] #print imageUrl #print chName addDir(chName ,chUrl ,10,imageUrl, False,isItFolder=False) #name,url,mode,icon else: chName=Colored(cname[1],'two',False); chUrl = cname[0] imageUrl = 'http://www.teledunet.com/tv_/icones/%s.jpg'%cname[0] #print imageUrl #print chName addDir(chName ,chUrl ,11,imageUrl, False,isItFolder=False) #name,url,mode,icon#<assignedcategory></assignedcategory> cstream+='<channel><id>%s</id><cname>%s</cname><imageurl>%s</imageurl><enabled>True</enabled></channel>'%(chUrl,cname[1],imageUrl) infostream+='<streaminginfo><id>%s</id><url>%s</url></streaminginfo>'%(chUrl,chUrl) cstream+='</channels>' infostream+='</streamingInfos>' #print cstream #print infostream return def PlayStream(url, name, mode): if mode==10: req = urllib2.Request(url) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) link=response.read() response.close() match =re.findall('file: "rtmp([^"]*)', link) rtmpLink=match[0] #rtmpLink='://192.95.32.7:1935/live/dubai_sport?user=MjA5N2Q3YjA2M2Q2ZjhiNWNjODAzYWJmM2RmNzU4YWE=&pass=fc9226bd032346a2deab1f903652229b' liveLink="rtmp%s app=live/ swfUrl=http://www.hdarabic.com/jwplayer.flash.swf pageUrl=http://www.hdarabic.com live=1 timeout=15"%rtmpLink else: newURL='http://www.teledunet.com/tv_/?channel=%s&no_pub'%url req = urllib2.Request(newURL) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') req.add_header('Referer',newURL) response = urllib2.urlopen(req) link=response.read() response.close() match =re.findall('time_player=(.*?);', link) match=str(long(float(match[0]))) liveLink='rtmp://5.135.134.110:1935/teledunet playpath=%s swfUrl=http://www.teledunet.com/tv_/player.swf?id0=%s&skin=bekle/bekle.xml&channel=%s pageUrl=http://www.teledunet.com/tv_/?channel=%s&no_pub live=1 timeout=15'%(url,match,url,url) #print 'liveLink',liveLink listitem = xbmcgui.ListItem( label = str(name), iconImage = "DefaultVideo.png", thumbnailImage = xbmc.getInfoImage( "ListItem.Thumb" ), path=liveLink ) xbmc.Player().play( liveLink,listitem) def getSourceAndStreamInfo(channelId, returnOnFirst,pDialog, filterBySource=""): try: ret=[] #Ssoup=getSoup('Sources.xml'); sourcesXml=getEtreeFromFile('Sources.xml'); default_source='' config=getChannelSettings( channelId) match_title='' if config and 'defaultsource' in config: default_source=config['defaultsource'].split(':')[0] try: match_title= ''.join(config['defaultsource'].split(':')[1:]) print 'match_title in settings',match_title,default_source except: pass #print 'default_source',default_source orderlist={} default_source_exists=False sources=sourcesXml.findall('source') total_sources=len(sources) print 'total_sources',total_sources for n in range(total_sources): val=selfAddon.getSetting( "order"+str(n+1) ) if val and not val=="": #print 'val',val,default_source orderlist[val]=n*100 if not default_source=='' and default_source ==val: orderlist[val]=-100 #print orderlist #print 'sources',sources num=0 pDialog.update(30, 'Looping on sources') GLArabServerLOW=selfAddon.getSetting( "GLArabServerLOW" ) GLArabServerHD=selfAddon.getSetting( "GLArabServerHD" ) GLArabServerMED=selfAddon.getSetting( "GLArabServerMED" ) GLArabServerLR=selfAddon.getSetting( "GLArabServerLR" ) glHDDisabled=False if not GLArabServerHD=="Disabled" else True glMedDisabled=False if not GLArabServerMED=="Disabled" else True glLowDisabled=False if not GLArabServerLOW=="Disabled" else True glLRDisabled=False if not GLArabServerLR=="Disabled" else True glproxyDisabled=not selfAddon.getSetting( "isGLProxyEnabled" )=="true" glproxyCommonDisabled=not selfAddon.getSetting( "isGLCommonProxyEnabled" )=="true" glproxyCommonDisabled=True #make it false if we get common proxy working # print "glHDDisabled",glHDDisabled for source in sources: sname = source.findtext('sname') num+=1 pDialog.update(30+(num*70)/len(sources) , 'Checking ..'+source.findtext('sname')) if not filterBySource=="": if not sname==filterBySource: continue try: #print 'source....................',source xmlfile = source.findtext('urlfile') isEnabled = source.findtext('enabled').lower() sid = source.findtext('id') #print 'sid',sid,xmlfile isAbSolutePath=False if sname=="Local": # isAbSolutePath=True isEnabled="false" filename=selfAddon.getSetting( "localstreampath" ).decode('utf-8') if filename and len(filename)>0: isEnabled="true" xmlfile=filename settingname="is"+sname.replace('.','')+"SourceDisabled" settingDisabled=selfAddon.getSetting(settingname) #print 'settingDisabled',settingDisabled if isEnabled=="true" and not settingDisabled=="true": #print 'source is enabled',sid #csoup=getSoup(xmlfile,isAbSolutePath); streamingxml=getEtreeFromFile(xmlfile,isAbSolutePath); #ccsoup = csoup("streaminginfo") #print 'csoup',csoup,channelId #print csoup #sInfo=csoup.findAll('streaminginfo',{'cname':re.compile("^"+channelId+"$", re.I)}) #sInfo=csoup.findAll('streaminginfo',{'cname':channelId}) #sInfo=csoup.findAll('streaminginfo',{'cname':channelId}) sInfos=streamingxml.findall('streaminginfo') sInfo=[] for inf in sInfos: if inf.findtext('cname').lower()==channelId.lower(): source_title='' # if match_title<>'': try: if source.findtext('id')=='generic': source_title=inf.find('item').findtext('title') else: source_title=inf.findtext('title') except: pass #print sname, glHDDisabled,source_title if sname=="GLArab" and glproxyDisabled and glproxyCommonDisabled and 'Proxy' in source_title: continue if sname=="GLArab" and glHDDisabled and glproxyCommonDisabled and "HD" in source_title : continue if sname=="GLArab" and glMedDisabled and glproxyCommonDisabled and "Med" in source_title: continue if sname=="GLArab" and glLowDisabled and glproxyCommonDisabled and "Low" in source_title: continue if sname=="GLArab" and glLRDisabled and glproxyCommonDisabled and "LR" in source_title: continue #print default_source,sid,match_title,inf.findtext('title'),inf if not default_source=='' and default_source==sname and (match_title =='' or match_title==source_title): default_source_exists=True sInfo.append(inf) name_find=sname if name_find in orderlist: order= orderlist[name_find] else: print 'not found',name_find,orderlist order=20000 order+=num if not sInfo==None and len(sInfo)>0: print 'sInfo...................',len(sInfo) for single in sInfo: source_title='' if match_title<>'': try: if source.findtext('id')=='generic': source_title=single.find('item').findtext('title') else: source_title=single.findtext('title') except: pass if (match_title =='' or match_title==source_title): print 'title match for order', match_title,source_title order-=1 ret.append([source,single,order]) #if returnOnFirst: # break; except: traceback.print_exc(file=sys.stdout) pass except: traceback.print_exc(file=sys.stdout) pass #print 'unsorted ret',ret #print ret ret= sorted(ret,key=lambda x:x[2]) print ret return ret,default_source_exists and not default_source=='' def selectSource(sources,fromSelectSource=False): if 1==1 or len(sources) > 1: #print 'total sources',len(sources) dialog = xbmcgui.Dialog() titles = [] for source in sources: (s,i,o) =source #print 'i',i.id,i if s.findtext('id')=="generic": try: #print 'trying generic name' titles.append(s.findtext('sname')+': '+i.find('item').findtext('title')) #print 'trying generic name end ' except: titles.append(s.findtext('sname')) else: try: titles.append(s.findtext('sname')+': '+i.findtext('title')) except: titles.append(s.findtext('sname')) if fromSelectSource: titles.append(Colored('Clear Default Source setting','one',True)) index = dialog.select('Choose your stream', titles) if index > -1: if index>len(sources)-1: return 'remove'#remove it else: return sources[index] else: return False def selectDefaultSourcesForChannel(channelId ): try: pDialog = xbmcgui.DialogProgress() ret = pDialog.create('XBMC', 'Finding available resources...') pDialog.update(20, 'Finding sources..') providers, default_source_exists=getSourceAndStreamInfo(channelId,False,pDialog) if len(providers)==0: pDialog.close() time = 2000 #in miliseconds line1="No sources found" xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) return None selectedprovider=selectSource(providers,True) if not selectedprovider: return None if selectedprovider=='remove': return '' fav_source='' source,sInfo,order=selectedprovider #pick first one fav_source=source.findtext('sname') try: if source.findtext('id')=="generic": fav_source=source.findtext('sname')+':'+sInfo.find('item').findtext('title') else: fav_source=source.findtext('sname')+':'+sInfo.findtext('title') except:pass return fav_source except: traceback.print_exc(file=sys.stdout) return None def PlayCommunityStream(channelId, name, mode): try: #print 'PlayCommunityStream' xbmcplugin.endOfDirectory(int(sys.argv[1])) pDialog = xbmcgui.DialogProgress() ret = pDialog.create('XBMC', 'Finding available resources...') #print 'channelId',channelId playFirst=selfAddon.getSetting( "playFirstChannel" ) if playFirst==None or playFirst=="" or playFirst=="false": playFirst=False else: playFirst=True playFirst=bool(playFirst) pDialog.update(20, 'Finding sources..') providers,default_source_exists=getSourceAndStreamInfo(channelId,playFirst,pDialog, sourceFilter) if default_source_exists: playFirst=True if len(providers)==0: pDialog.close() time = 2000 #in miliseconds line1="No sources found" xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) return pDialog.update(30, 'Processing sources..') pDialog.close() #source=providers[""] enforceSourceSelection=False #print 'playFirst',playFirst done_playing=False current_index=0 auto_skip=False auto_skip=True if selfAddon.getSetting( "playOneByOne" )=="true" else False while not done_playing: #print 'trying again',enforceSourceSelection ret = pDialog.create('XBMC', 'Trying to play the source') #print 'dialogue creation' done_playing=True if (enforceSourceSelection or (len (providers)>1 and not playFirst)) and not auto_skip: #print 'select sources' selectedprovider=selectSource(providers) if not selectedprovider: return else: selectedprovider=providers[current_index] enforceSourceSelection=True #print 'picking source' (source,sInfo,order)=selectedprovider #pick first one #print source processor = source.findtext('processor') sourcename = source.findtext('sname') if communityStreamPath not in sys.path: sys.path.append(communityStreamPath) #print processor #from importlib import import_module processorObject=import_module(processor.replace('.py','')) pDialog.update(60, 'Trying to play..') pDialog.close() sinfoSoup= BeautifulSOAP(etree.tostring(sInfo), convertEntities=BeautifulStoneSoup.XML_ENTITIES) done_playing=processorObject.PlayStream(source,sinfoSoup,name,channelId) #print 'done_playing',done_playing if not done_playing: time = 2000 #in miliseconds line1="Failed playing from "+sourcename xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) if auto_skip: done_playing=False current_index+=1 if current_index>len(providers): done_playing=True if not done_playing: (s,i,o) =providers[current_index] titles='' if s.findtext('id')=="generic": try: #print 'trying generic name' titles=s.findtext('sname')+': '+i.find('item').findtext('title') #print 'trying generic name end ' except: titles=s.findtext('sname') else: try: titles=s.findtext('sname')+': '+i.findtext('title') except: titles=s.findtext('sname') ret = pDialog.create('XBMC', 'Trying to play the Item# %d of %d, Cancel in 3 seconds.\n Source:%s'%(current_index+1, len(providers),titles)) xbmc.sleep(3000) if pDialog.iscanceled(): current_index=0 done_playing=False enforceSourceSelection=True auto_skip=False #print 'donexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' return except: traceback.print_exc(file=sys.stdout) def import_module(name, package=None): """Import a module. The 'package' argument is required when performing a relative import. It specifies the package to use as the anchor point from which to resolve the relative import to an absolute import. """ if name.startswith('.'): if not package: raise TypeError("relative imports require the 'package' argument") level = 0 for character in name: if character != '.': break level += 1 name = _resolve_name(name[level:], package, level) __import__(name) return sys.modules[name] def getUrl(url, cookieJar=None,post=None,referer=None,isJsonPost=False, acceptsession=None): cookie_handler = urllib2.HTTPCookieProcessor(cookieJar) opener = urllib2.build_opener(cookie_handler, urllib2.HTTPBasicAuthHandler(), urllib2.HTTPHandler()) #opener = urllib2.install_opener(opener) req = urllib2.Request(url) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') if isJsonPost: req.add_header('Content-Type','application/json') if acceptsession: req.add_header('Accept-Session',acceptsession) if referer: req.add_header('Referer',referer) response = opener.open(req,post,timeout=30) link=response.read() response.close() return link; def performShahidLogin(pDialog=None): try: cookieJar=cookielib.LWPCookieJar() userName=selfAddon.getSetting( "ShahidVodLogin" ) password=selfAddon.getSetting( "ShahidVodPwd" ) pDialog.update(10, 'login being processed stage 0') html_text=getUrl(getMainUrl()+"/arContent/getPlayerContent-param-.id-0.type-player.html",cookieJar,referer='https://shahid.mbc.net/ar/widgets.html?widget=login') post={'email':userName,'password':password} post = json.dumps(post) #post = urllib.urlencode(post) import uuid json_text=getUrl(getMainUrl()+"/wd/service/users/login?"+str(uuid.uuid4()),cookieJar,post,referer='https://shahid.mbc.net/ar/widgets.html?widget=login', isJsonPost=True) cookieJar.save (ShahidCOOKIEFILE,ignore_discard=True) pDialog.update(20, 'login processed stage 1') print repr(cookieJar) acceptsessionVal='' for index, cookie in enumerate(cookieJar): print cookie.name, cookie.path if cookie.name=='JSESSIONID' and 'api-new' in cookie.path : acceptsessionVal=cookie.value print 'acceptsessionVal',acceptsessionVal html_text=getUrl(getMainUrl()+"/wd/service/payment/getDefaultPaymentsInstrument?"+str(uuid.uuid4()),cookieJar,None,referer='https://shahid.mbc.net/ar/widgets.html?widget=login', isJsonPost=True,acceptsession=acceptsessionVal) pDialog.update(30, 'login being processed stage 3') userDetails = json.loads(json_text) userDetails=userDetails["user"] firstName=userDetails["firstName"]#firstName lastName=userDetails["lastName"]#lastName userName=userDetails["userName"]#userName csg_user_name=userDetails["userName"]#userName subscriberId=userDetails["id"] #id post={'firstName':firstName,'lastName':lastName,'userName':userName,'csg_user_name':csg_user_name,'subscriberId':subscriberId,'sessionId':acceptsessionVal} post = urllib.urlencode(post) html_text=getUrl(getMainUrl()+"/populateContext",cookieJar,post,referer='https://shahid.mbc.net/ar/widgets.html?widget=login') pDialog.update(40, 'login being processed stage 4') cookieJar.save (ShahidCOOKIEFILE,ignore_discard=True) pDialog.update(45, 'login being processed') return shouldShahidforceLogin(cookieJar)==False except: traceback.print_exc(file=sys.stdout) return False def shouldShahidforceLogin(cookieJar=None): try: url=getMainUrl() if not cookieJar: cookieJar=getShahidCookieJar() # import uuid html_txt=getUrl(getMainUrl()+"/arContent/getPlayerContent-param-.id-108122.type-player.html?",cookieJar,None,acceptsession=None) #html_txt=getUrl(url,cookieJar) if not 'shahid.net/mediaDelivery/media' in html_txt: return True else: return False except: traceback.print_exc(file=sys.stdout) return True def getShahidCookieJar(): cookieJar=None try: cookieJar = cookielib.LWPCookieJar() cookieJar.load(ShahidCOOKIEFILE,ignore_discard=True) except: cookieJar=None if not cookieJar: cookieJar = cookielib.LWPCookieJar() return cookieJar def processProxyLogin(): userName=selfAddon.getSetting( "ShahidVodLogin" ) password=selfAddon.getSetting( "ShahidVodPwd" ) post={'user':userName,'pwd':password} post = urllib.urlencode(post) html_txt=getUrl(getMainUrl()+"/proxychecklogin.php?",None,post) return cookielib.LWPCookieJar() def processShahidLogin(pDialog=None): try: loginName=selfAddon.getSetting( "ShahidVodLogin" ) pDialog.update(10, 'Checking login status') if not loginName=="": if selfAddon.getSetting( "isProxyEnabled" )=="true": return processProxyLogin() if shouldShahidforceLogin(): if performShahidLogin(pDialog): print 'done login' else: print 'login failed??' else: print 'Login not forced.. perhaps reusing the session' cookie_jar=getShahidCookieJar() else: cookie_jar=cookielib.LWPCookieJar() pDialog.update(50, 'login processed') return cookie_jar except: print 'Error while here' traceback.print_exc(file=sys.stdout) def PlayShowLink ( url ): pDialog = xbmcgui.DialogProgress() ret = pDialog.create('Shahid', 'Trying to resolve the url') processShahidLogin(pDialog) cookiejar=getShahidCookieJar(); # url = tabURL.replace('%s',channelName); line1 = "Finding stream" time = 500 #in miliseconds # line1 = "Playing video Link" # xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) # print url # req = urllib2.Request(url) # req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36') # response = urllib2.urlopen(req) # link=response.read() # response.close() # print url pDialog.update(60, 'reading the page') if mode==32: #print "PlayLINK" videoID=url else: #print "PlayLINK" link=getUrl(url) playURL= match =re.findall('id : "(.*?)",\s*pricingPlanId : "(.*?)"', link) videoID=match[0][0]# check if not found then try other methods paymentID=match[0][1] # playlistURL=getMainUrl()+"/arContent/getPlayerContent-param-.id-%s.type-playegr.html" % ( videoID) loginName=selfAddon.getSetting( "ShahidVodLogin" ) if not loginName=="" or mode==32: playlistURL=getMainUrl()+"/arContent/getPlayerContent-param-.id-%s.type-player.html?" % ( videoID) link=getUrl(playlistURL,cookiejar) else: cJar=cookielib.LWPCookieJar() getUrl('http://proxyusa.org/index.php',cJar); urltoget='http://api.shahid.net/api/Content/Episode/'+videoID+'/8879?apiKey=sh%40hid0nlin3&hash=b2wMCTHpSmyxGqQjJFOycRmLSex%2BBpTK%2Fooxy6vHaqs%3D' post={'u':urltoget,'encodeURL':'on','allowCookies':'on','stripJS':'on','stripObjects':'on'} post = urllib.urlencode(post) link= getUrl('http://proxyusa.org/includes/process.php?action=update',cJar,post) # '''req = urllib2.Request(playlistURL) # req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36') # response = urllib2.urlopen(req) # link=response.read() #''' print link pDialog.update(70, 'Linked fetched') # print link #response.close() patt='({.*})' link=re.findall(patt, link)[0] jsonData=json.loads(link) # print jsonData; url=jsonData["data"]["url"] #print url pDialog.update(80, 'getting Json') defaultCDN="Default" defaultCDN=selfAddon.getSetting( "DefaultCDN" ) #print 'default CDN',defaultCDN,cdnType changeCDN="" #print 'tesing if cdn change is rquired' if cdnType=="l3" or (cdnType=="" and defaultCDN=="l3"): changeCDN="l3" elif cdnType=="xdn" or (cdnType=="" and defaultCDN=="xdn"): changeCDN="xdn" elif cdnType=="ak" or (cdnType=="" and defaultCDN=="ak"): changeCDN="ak" #print 'changeCDN',changeCDN if len(changeCDN)>0: #print 'Changing CDN based on critertia',changeCDN #http://l3md.shahid.net/web/mediaDelivery/media/12af648b9ffe4423a64e8ab8c0100701.m3u8?cdn=l3 #print 'url received',url playURL= re.findall('\/media\/(.*?)\.', url) url="http://%smd.shahid.net/web/mediaDelivery/media/%s.m3u8?cdn=%s" % (changeCDN,playURL[0],changeCDN) #print 'new url',url line1 = "Using the CDN %s" % changeCDN time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) pDialog.update(100, 'going to play') cName=name listitem = xbmcgui.ListItem( label = str(cName), iconImage = "DefaultVideo.png", thumbnailImage = xbmc.getInfoImage( "ListItem.Thumb" ), path=url ) #print "playing stream name: " + str(cName) listitem.setInfo( type="video", infoLabels={ "Title": cName, "Path" : url } ) listitem.setInfo( type="video", infoLabels={ "Title": cName, "Plot" : cName, "TVShowTitle": cName } ) #print 'playurl',url pDialog.close() xbmc.Player().play( url,listitem) #print 'ol..' return def addToMyChannels(cname): try: fileName=os.path.join(profile_path, 'MyChannels.xml') print fileName MyChannelList=getSoup(fileName,True) except: MyChannelList=None if not MyChannelList: MyChannelList= BeautifulSOAP('<channels></channels>') val=MyChannelList.find("channel",{"cname":cname}) #print 'val is ',val if not val: channeltag = Tag(MyChannelList, "channel") channeltag['cname']=cname #cnametag = Tag(MyChannelList, "cname") #ctext = NavigableString(cname) #cnametag.insert(0, ctext) #channeltag.insert(0, cnametag) MyChannelList.channels.insert(0, channeltag) #print MyChannelList.prettify() with open(fileName, "wb") as filewriter: filewriter.write(str(MyChannelList)) def removeFromMyChannels(cname): try: fileName=os.path.join(profile_path, 'MyChannels.xml') print fileName MyChannelList=getSoup(fileName,True) except: return if not MyChannelList: return val=MyChannelList.find("channel",{"cname":cname}) if val: #print 'val to be deleted',val val.extract() with open(fileName, "wb") as filewriter: filewriter.write(str(MyChannelList)) def ShowSources(url): #soup=getSoup('Categories.xml'); cats=getEtreeFromFile('Sources.xml'); #print cats for cat in cats.findall('source'): isEnabled = cat.findtext('enabled').lower() chName=cat.findtext('sname') chUrl = cat.findtext('id') settingname="is"+chName.replace('.','')+"SourceDisabled" settingDisabled=selfAddon.getSetting(settingname) imageUrl = cat.findtext('imageurl') if isEnabled=="true" and not settingDisabled=="true": addDir(chName ,chUrl ,26,imageUrl, False,isItFolder=True, BySource=chName) #name,url,mode,icon return def addCommunityCats(): #soup=getSoup('Categories.xml'); cats=getEtreeFromFile('Categories.xml'); #print cats if sourceFilter=="": addDir('My Channels' ,'My Channels' ,15,addonArt+'/mychannels.png', False,isItFolder=True) #name,url,mode,icon addDir('By Sources' ,'By Sources' ,25,addonArt+'/bysource.png', False,isItFolder=True) #name,url,mode,icon else: sources=getSourceList() source = sources[sourceFilter] sourceName=source[0] SourceFileName=source[2] SourceImageName=source[3] isAbsolutePath=source[4] addDir('** Filtered by ' + sourceName+' **','' ,99,SourceImageName, False,isItFolder=False ) for cat in cats.findall('category'): chName=cat.findtext('catname') chUrl = cat.findtext('id') imageUrl = cat.findtext('imageurl') addDir(chName ,chUrl ,15,imageUrl, False,isItFolder=True,BySource=sourceFilter) #name,url,mode,icon return def getSourceList(): sourcesXml=getEtreeFromFile('Sources.xml'); sources_list={} for sources in sourcesXml.findall('source'): id=sources.findtext('id') sname=sources.findtext('sname') ssname=sources.findtext('shortname') scolour=sources.findtext('colour') urlfile=sources.findtext('urlfile') imageUrl=sources.findtext('imageurl') isAbSolutePath=False if sname=="Local": isAbSolutePath=True filename=selfAddon.getSetting( "localstreampath" ).decode('utf-8') if filename and len(filename)>0: urlfile=filename sources_list[sname]=[ssname,scolour,urlfile,imageUrl, isAbSolutePath ] return sources_list def getSourceChannelList(fileName, isAbsolutePath): sourcesXml=getEtreeFromFile(fileName,isAbsolutePath ); sources_list={} for sources in sourcesXml.findall('streaminginfo'): cname=sources.findtext('cname') sources_list[cname]=[cname] return sources_list def getCommunityChannels(catType): #soup=getSoup('Channels.xml');#changetoEtree Channelsxml=getEtreeFromFile('Channels.xml') #channels=soup('channel') retVal=[] #for channel in channels: searchCall='channel' #if not catType=="all": searchCall='.//category' #print searchCall MyChannelList=None hidechanneloption=True sourcesXml=getEtreeFromFile('Sources.xml'); sources_list={} for sources in sourcesXml.findall('source'): sname=sources.findtext('sname') ssname=sources.findtext('shortname') scolour=sources.findtext('colour') sources_list[sname]=[ssname,scolour] if catType=="My Channels": try: fileName=os.path.join(profile_path, 'MyChannels.xml') #print fileName MyChannelList=getSoup(fileName,True) #print MyChannelList except: MyChannelList=None for channel in Channelsxml.findall('channel'): #print channel chName=channel.findtext('cname') if 1==1: config=getChannelSettings( chName) #print 'config is ',config if not catType=="all": exists=False if not catType=="My Channels": supportCats= channel.findall(searchCall) if len(supportCats)==0: continue for c in supportCats: if c.text.lower()==catType.lower(): exists=True break else: #check if channel exists in file if MyChannelList: val=MyChannelList.find("channel",{"cname":chName}) if val: exists=True if config and 'hidden' in config: exists=not config['hidden']=="yes" if not exists: continue if config and 'hidden' in config: hidechanneloption=not config['hidden']=="yes" #chUrl = channel.id.text imageUrl =channel.findtext('imageurl') chUrl=chName if config and 'defaultsource' in config: default_source=config['defaultsource'].split(':')[0] #chName+='['+default_source+']' if default_source in sources_list: short_name='['+sources_list[default_source][0]+']' colour=sources_list[default_source][1] short_name=Colored(text = short_name, colorid = colour, isBold = False) print short_name chName+=' '+short_name retVal.append([chUrl,chName,imageUrl,hidechanneloption]) return retVal def addCommunityChannels(catType): channels=getCommunityChannels(catType) channels=sorted(channels,key=lambda x:x[1].lower()) FilterBySource=False ExistsInSource=False print 'Source Filter',sourceFilter if not sourceFilter=="": FilterBySource=True sources=getSourceList() source = sources[sourceFilter] sourceName=source[0] SourceFileName=source[2] SourceImageName=source[3] isAbsolutePath=source[4] addDir('** Filtered by ' + sourceName+' **','' ,99,SourceImageName, False,isItFolder=False ) streamingxml=getEtreeFromFile(SourceFileName,isAbsolutePath); sInfos=streamingxml.findall('streaminginfo') sInfo=getSourceChannelList(SourceFileName, isAbsolutePath ) #print sInfo for channel in channels: ExistsInSource=False chName=channel[1] chUrl = channel[0] imageUrl = channel[2] hideChannel=channel[3] addRemoveMyChannel=not catType=="My Channels" #print chName,chName in sInfo, if FilterBySource and not chUrl in sInfo: continue addDir(chName ,chUrl ,16,imageUrl, False,isItFolder=False,AddRemoveMyChannels=addRemoveMyChannel, SelectDefaultSource=True,hideChannel=hideChannel, BySource=sourceFilter ) #name,url,mode,icon return def setChannelSettings(cname,settingName,SettingVal): current_setting=getChannelSettings(cname) if current_setting==None: current_setting={settingName:SettingVal} else: current_setting[settingName]=SettingVal #print 'current_setting',current_setting saveChannelSettings(cname,current_setting) def getChannelSettings(cname): current_string=selfAddon.getSetting( cname+"-settings") #print cname+"-settings",current_string if current_string=="": return None #print 'current_string',current_string return json.loads(current_string) def saveChannelSettings(cname, json_data): store="" if json_data: store=json_data selfAddon.setSetting( id=cname+"-settings" ,value=json.dumps(store)) def getEtreeFromFile(fileName, isabsolutePath=False): try: #print 'communityStreamPath',communityStreamPath #print 'fileName',fileName strpath=os.path.join(communityStreamPath, fileName) #print 'strpath',strpath if isabsolutePath: strpath=fileName data = open(strpath, "r").read() return getETreeFromString(data) except: print 'somethingwrong' traceback.print_exc(file=sys.stdout) #obselete def getSoup(fileName, isabsolutePath=False): strpath=os.path.join(communityStreamPath, fileName) if isabsolutePath: strpath=fileName data = open(strpath, "r").read() return BeautifulSOAP(data)#, convertEntities=BeautifulStoneSoup.XML_ENTITIES) #return BeautifulStoneSoup(data,convertEntities=BeautifulStoneSoup.XML_ENTITIES); def getETreeFromUrl(video_url): req = urllib2.Request(video_url) req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) data=response.read() response.close() return getETreeFromString(data) #return BeautifulSOAP(data) def getETreeFromString(str): return etree.fromstring(str) def getStreams(): defaultStream="All" defaultStream=selfAddon.getSetting( "DefaultStream" ) if defaultStream=="": defaultStream="All" hdArab= [('Al Jazeera','http://www.hdarabic.com/aljazeera.php','jazeera'), ('Al Jazeera Mubasher','http://www.hdarabic.com/aljazeera.php','jazeera'), ('Al Jazeera Egypt','http://www.hdarabic.com/aljazeera.php','jazeera'), ('Al Jazeera Documentary','http://www.hdarabic.com/aljazeera.php','jazeera'), ('Al Jazeera English','http://www.hdarabic.com/aljazeera.php','jazeera'), ('Al Jazeera America','http://www.hdarabic.com/aljazeera.php','jazeera'), ('Hurra Iraq','http://www.hdarabic.com/alhurra_iraq.php','hurra_iraq'), ('Al Iraqia','http://www.hdarabic.com/aliraqiya.php','iraqiay'), ('SemSem','http://www.hdarabic.com/semsem.php','semsem_tv'), ('Al Arabiya','http://www.hdarabic.com/alarabiya.php','alarabiya'), ('France 24','http://www.hdarabic.com/f24.php','f24'), ('France 24 English','http://www.hdarabic.com/f24.php','f24'), ('France 24 France','http://www.hdarabic.com/f24.php','f24'), ('Al hiwar','http://www.hdarabic.com/alhiwar.php','alhiwar'), ('Skynews','http://www.hdarabic.com/skynews.php','skynews'), ('Skynews English','http://www.hdarabic.com/skynews.php','skynews'), ('BBC Arabic','http://www.hdarabic.com/bbc.php','bbc'), ('Al mayadeen','http://www.hdarabic.com/almayaden.php','almayaden'), ('TAHA','http://www.hdarabic.com/taha.php','taha'), ('National Wild','http://www.hdarabic.com/national_wild.php','national_wild'), ('National Geographic Abu','http://www.hdarabic.com/national.php','ng'), ('HODHOD','http://www.hdarabic.com/hod_hod.php','hod_hod'), ('Karamesh','http://www.hdarabic.com/karamesh.php','karamesh'), ('Al Jazeera Children','http://www.hdarabic.com/jazeerakids.php','jsckids'), ('Qatar','http://www.hdarabic.com/qatar.php','qatar'), ('Tunisia 1','http://www.hdarabic.com/tunis1.php','tunisia1'), ('Tunisia 2','http://www.hdarabic.com/tunisia_2.php','tv_tunisia2'), ('Sama Dubai','http://www.hdarabic.com/sama_dubai.php','Sama-dubai'), ('B4U plus','http://www.hdarabic.com/b4u+.php','b4u+'), ('B4U Aflam','http://www.hdarabic.com/b4u_aflam.php','b4u_aflam'), ('Saudi Sport','http://www.hdarabic.com/saudi_sport.php','saudi_sport'), ('Dubai Sport','http://www.hdarabic.com/dubai_sport.php','dubai-sport'), ('Dubai Sport 3','http://www.hdarabic.com/dubai_sport_3.php','dubai-sport'), ('Dubai Racing','http://www.hdarabic.com/dubai_racing.php','dubai_racing'), ('Oman','http://www.hdarabic.com/oman.php','oman_tv'), ('Dubai','http://www.hdarabic.com/dubai.php','dubai'), ('Play Hekayat','http://www.hdarabic.com/play_hekayat.php','play_hekayat'), ('Watan','http://www.hdarabic.com/play_hekayat.php','watan'), ('Watan Plus','http://www.hdarabic.com/play_hekayat.php','watan_plus'), ('Watan ghanawi','http://www.hdarabic.com/play_hekayat.php','watan_ghanawi'), ('Fox Movie','http://www.hdarabic.com/fox_movie.php','fox_movies'), ('ART Aflam 1','http://www.hdarabic.com/art_1.php','art1'), ('ART Aflam 2','http://www.hdarabic.com/art2.php','art_aflam2'), ('ART Cinema ','http://www.hdarabic.com/art.php','art'), ('ART Hekayat','http://www.hdarabic.com/art_hekayat.php','art_hekayat'), ('ART Hekayat 2','http://www.hdarabic.com/art_hekayat_2.php','art_hekayat_2'), ('Melody Arabia','http://www.hdarabic.com/melody.php','melodytv'), ('Melody Aflam','http://www.hdarabic.com/melody_aflam.php','melodytv'), ('Melody Classic','http://www.hdarabic.com/melody_classic.php','melodytv'), ('Melody Hits','http://www.hdarabic.com/melody_hits.php','melodytv'), ('Melody Drama','http://www.hdarabic.com/melody_drama.php','melodytv'), ('Mehwar','http://www.hdarabic.com/mehwar.php','mehwar'), ('Mehwar 2','http://www.hdarabic.com/mehwar2.php','mehwar2'), ('Talaki','http://www.hdarabic.com/mehwar2.php','talaki'), ('Syria News','http://www.hdarabic.com/mehwar2.php','syria_news'), ('Oscar Drama','http://www.hdarabic.com/oscar_drama.php','oscar_drama'), ('Cima','http://www.hdarabic.com/cima.php','cima'), ('Cairo Cinema','http://www.hdarabic.com/cairo_cinema.php','cairo_cinema'), ('Cairo Film','http://www.hdarabic.com/cairo_film.php','cairo_film'), ('Cairo Drama','http://www.hdarabic.com/cairo_drama.php','cairo_drama'), ('IFilm Arabic','http://www.hdarabic.com/cairo_drama.php','ifilm'), ('IFilm English','http://www.hdarabic.com/cairo_drama.php','ifilm'), ('IFilm Farsi','http://www.hdarabic.com/cairo_drama.php','ifilm'), ('Gladiator','http://www.hdarabic.com/gladiator.php','gladiator'), ('ESC1','http://www.hdarabic.com/esc1.php','al_masriya_eg'), ('ESC2','http://www.hdarabic.com/esc2.php','masriaesc2'), ('Bein Sport 1','http://www.hdarabic.com/jsc1.php','bein_sport'), ('Bein Sport 2','http://www.hdarabic.com/jsc2.php','bein_sport'), ('Bein Sport 3','http://www.hdarabic.com/jsc3.php','bein_sport'), ('Bein Sport 4','http://www.hdarabic.com/jsc4.php','bein_sport'), ('Bein Sport 5','http://www.hdarabic.com/jsc5.php','bein_sport'), ('Bein Sport 6','http://www.hdarabic.com/jsc6.php','bein_sport'), ('Bein Sport 7','http://www.hdarabic.com/jsc7.php','bein_sport'), ('Bein Sport 8','http://www.hdarabic.com/jsc8.php','bein_sport'), ('Bein Sport 11','http://www.hdarabic.com/jsc9.php','bein_sport'), ('Bein Sport 12','http://www.hdarabic.com/jsc10.php','bein_sport'), ('Panorama Film','http://www.hdarabic.com/panorama_film.php','panorama_film'), ('TF1','http://www.hdarabic.com/tf1.php','tf1'), ('M6 Boutique','http://www.hdarabic.com/m6_boutique.php','m6'), ('TV5','http://www.hdarabic.com/tv5.php','tv5_monde_europe'), ('Guilli','http://www.hdarabic.com/guilli.php','guilli'), ('Libya','http://www.hdarabic.com/libya.php','libya'), ('Assema','http://www.hdarabic.com/assema.php','assema'), ('Libya Awalan','http://www.hdarabic.com/libya_awalan.php','libya_awalan'), ('RTM Tamazight','http://www.hdarabic.com/tamazight.php','tamazight'), ('Al maghribiya','http://www.hdarabic.com/maghribiya.php','maghribiya'), ('Sadissa','http://www.hdarabic.com/sadissa.php','sadisa'), ('A3','http://www.hdarabic.com/a3.php','a3'), ('Algerie 4','http://www.hdarabic.com/algerie_4.php','algerie_4'), ('Algerie 5','http://www.hdarabic.com/algerie5.php','algerie5'), ('Al Nahar Algerie','http://www.hdarabic.com/nahar_algerie.php','nahar_algerie'), ('Chorouk TV','http://www.hdarabic.com/chorouk.php','chorouk'), ('El Beit Beitak','http://www.hdarabic.com/beitak.php','beitak'), ('Insen','http://www.hdarabic.com/insen.php','insen'), ('Nesma','http://www.hdarabic.com/nesma.php','rouge'), ('Tounsiya','http://www.hdarabic.com/tounsiya.php','tounsiya'), ('Aghanina','http://www.hdarabic.com/aghanina.php','aghanina'), ('Nojoom','http://www.hdarabic.com/nojoom.php','nojoom'), ('Funoon','http://www.hdarabic.com/funoon.php','funoon'), ('Mazazik','http://www.hdarabic.com/mazazik.php','mazazik'), ('Mazzika','http://www.hdarabic.com/mazzika.php','logo-mazzika'), ('Power Turk','http://www.hdarabic.com/power_turk.php','power_turk'), ('Al Haneen','http://www.hdarabic.com/alhaneen.php','alhaneen'), ('Heya','http://www.hdarabic.com/heya.php','heya'), ('CBC','http://www.hdarabic.com/cbc.php','cbc'), ('CBC Extra','http://www.hdarabic.com/cbc.php','cbc_extra'), ('CBC Drama','http://www.hdarabic.com/cbc_drama.php','cbc_drama'), ('CBC Sofra','http://www.hdarabic.com/cbc_sofra.php','cbc_sofra'), ('Al Hayat 2 TV ','http://www.hdarabic.com/hayat_2.php','hayat_2'), ('Top Movies ','http://www.hdarabic.com/top_movie.php','top_movies_eg'), ('Dream 1','http://www.hdarabic.com/dream1.php','dream1'), ('Nile Comedy','http://www.hdarabic.com/nile_comedy.php','nile_comedy'), ('Nile News','http://www.hdarabic.com/nile_news.php','nile_news'), ('Nile Family','http://www.hdarabic.com/nile_family.php','nile_family'), ('Nile Education','http://www.hdarabic.com/nile_educ.php','nile_educational'), ('Rotana Cinema','http://www.hdarabic.com/rotana_cinema.php','rotana_cinema'), ('Rotana Clip','http://www.hdarabic.com/rotana_clip.php','rotana_clip'), ('Rotana Classic','http://www.hdarabic.com/rotana_classic.php','rotana_classic'), ('Rotana Khalijia','http://www.hdarabic.com/rotana_khalijiya.php','rotana-khalijia'), ('ANB','http://www.hdarabic.com/anb.php','anb'), ('MTV Lebanon','http://www.hdarabic.com/mtvlebanon.php','mtv1'), ('Arabica ','http://www.hdarabic.com/arabica.php','arabica-tv'), ('MTV Arabia','http://www.hdarabic.com/mtv_arabia.php','mtv_arabia'), ('MBC','http://www.hdarabic.com/mbc.php','mbc'), ('MBC 2','http://www.hdarabic.com/mbc2.php','mbc2'), ('MBC 3','http://www.hdarabic.com/mbc3.php','mbc3'), ('MBC Action','http://www.hdarabic.com/mbc_action.php','mbc_action'), ('MBC Max','http://www.hdarabic.com/mbc_max.php','mbc_max'), ('MBC Drama','http://www.hdarabic.com/mbc_drama.php','mbc_drama'), ('MBC Masr','http://www.hdarabic.com/mbc_masr.php','mbc_masr'), ('MBC Masr Drama','http://www.hdarabic.com/mbc_masr_drama.php','mbc_masr_drama'), ('MBC Bollywood','http://www.hdarabic.com/mbc_bollywood.php','mbc_bollywoodl'), ('Wanasah','http://www.hdarabic.com/wanasah.php','wanasah'), ('Al Nahar','http://www.hdarabic.com/nahar_egy.php','Nahar-TV'), ('Nahar +2','http://www.hdarabic.com/nahar_egy.php','nahar+2'), ('Nahar Sport','http://www.hdarabic.com/nahar_sport.php','al_nahar_sport'), ('LBC Europe','http://www.hdarabic.com/lbc_europe.php','lbc'), ('Tele Liban','http://www.hdarabic.com/teleliban.php','teleliban'), ('Syria ','http://www.hdarabic.com/syria.php','syria'), ('Sama Syria ','http://www.hdarabic.com/sama_syria.php','sama_syria'), ('MBC Maghreb','http://www.hdarabic.com/mbc_maghreb.php','mbc_maghreb'), ('Abu Dhabi Sport','http://www.hdarabic.com/abu_dhabi_sport.php','abu_dhabi_sporti'), ('Abu Dhabi','http://www.hdarabic.com/abu_dhabi_sport.php','abudhabi'), ('Abu Dhabi Emarate','http://www.hdarabic.com/abu_emarat.php','abu_dhabi_al_emarat'), ('Bahrain','http://www.hdarabic.com/bahrein.php','bahrain_tv'), ('Kuwait','http://www.hdarabic.com/kowait1.php','kuwait'), ('Kuwait 2','http://www.hdarabic.com/kowait2.php','kuwait2'), ('Kuwait 3','http://www.hdarabic.com/kowait3.php','kuwait3'), ('Kuwait 4','http://www.hdarabic.com/kowait4.php','kuwait4'), ('Kuwait 5','http://www.hdarabic.com/kowait5.php','kuwait5'), ('Kuwait 6','http://www.hdarabic.com/kowait6.php','kuwait6'), ('LBC','http://www.hdarabic.com/lbc.php','lbc'), ('LBC Drama','http://www.hdarabic.com/lbc_drama.php','lbc_drama'), ('LDC','http://www.hdarabic.com/ldc.php','ldc'), ('AL Sharqia','http://www.hdarabic.com/sharqia.php','sharqia'), ('Al Sharqia News','http://www.hdarabic.com/sharqia_news.php','al_sharqiya_news'), ('Orient News','http://www.hdarabic.com/orient_news.php','orientnews'), ('Al Alam','http://www.hdarabic.com/alalam.php','alalam'), ('Nabaa ','http://www.hdarabic.com/nabaa.php','nabaa_tv_sa'), ('Baghdadia ','http://www.hdarabic.com/baghdad.php','al-baghdadia'), ('Baghdadia 2','http://www.hdarabic.com/baghdad2.php','baghdad2'), ('Kaifa','http://www.hdarabic.com/kaifa.php','kaifa'), ('Suna Nabawiya','http://www.hdarabic.com/sunah.php','sunah'), ('Iqrae','http://www.hdarabic.com/iqra.php','iqra'), ('Rahma','http://www.hdarabic.com/rahma.php','rahma'), ('Al Maaref','http://www.hdarabic.com/almaaref.php','almaaref'), ('Sirat','http://www.hdarabic.com/sirat.php','sirat'), ('Wesal TV','http://www.hdarabic.com/wesal.php','wesal_tv'), ('Al Majd Massah','http://www.hdarabic.com/majd_massah.php','al_majd'), ('Al Majd Nature','http://www.hdarabic.com/majd_nature.php','al_majd'), ('Al Afassi','http://www.hdarabic.com/afasi.php','afasi'), ('Al AAN','http://www.hdarabic.com/alan.php','al_aan_tv'), ('Al Ressala','http://www.hdarabic.com/resala.php','alressala'), ('Ctv Coptic','http://www.hdarabic.com/ctv_coptic.php','ctv_eg'), ('Sat7','http://www.hdarabic.com/sat7.php','sat7'), ('Sat7 Kids','http://www.hdarabic.com/sat7_kids.php','sat7_kids'), ('Aghapy','http://www.hdarabic.com/aghapy.php','aghapy_tv'), ('Noursat','http://www.hdarabic.com/nour_sat.php','nour_sat'), ('Miracle','http://www.hdarabic.com/miracle.php','miracle'), ('Royali Somali','http://www.hdarabic.com/royali_somali.php','royali_somali'), ('Somali Channel','http://www.hdarabic.com/somali_channel.php','somali_channel'), ('Cartoon Network','http://www.hdarabic.com/cartoon.php','cartoon_network'), ('Baraem','http://www.hdarabic.com/baraem.php','baraem_95x64'), ('Space Power','http://www.hdarabic.com/space_power.php','space_power'), ('Majd Kids','http://www.hdarabic.com/majd_kids.php','majd_kids'), ('Majd Kids 2','http://www.hdarabic.com/majd_kids_2.php','majd_kids'), ('Majd Roda','http://www.hdarabic.com/majd_roda.php','almajd'), ('Majd Taghrid','http://www.hdarabic.com/majd_taghrid.php','almajd'), ('Toyor Al Janah 1','http://www.hdarabic.com/toyorjana1.php','toyor'), ('Toyor Baby','http://www.hdarabic.com/toyorbaby.php','baby'), ('Ajyal','http://www.hdarabic.com/ajyal.php','ajyal'), ('ANN','http://www.hdarabic.com/ann.php','ann_95x44'), ('Al Magharibiya','http://www.hdarabic.com/magharibia.php','http://tv.webactu-webtv.com/algerie1/magharibia.png')] if defaultStream=="hdarabic.com": return hdArab req = urllib2.Request('http://www.teledunet.com/') req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36') response = urllib2.urlopen(req) link=response.read() response.close() match =re.findall('set_favoris\(\'(.*?)\',\'(.*?)\'\s?(.)', link) if defaultStream=="teledunet.com": return match return match+hdArab #print "i am here" params=get_params() url=None name=None mode=None linkType=None pageNumber=None AddRemoveMyChannels=None sourceFilter="" try: sourceFilter=urllib.unquote_plus(params["sourceFilter"]) except: pass print 'sourceFilter',sourceFilter try: url=urllib.unquote_plus(params["url"]) except: pass try: name=urllib.unquote_plus(params["name"]) except: pass try: mode=int(params["mode"]) except: pass try: pageNumber=params["pagenum"] except: pageNumber=""; args = cgi.parse_qs(sys.argv[2][1:]) cdnType='' try: cdnType=args.get('cdnType', '')[0] except: pass addIconForPlaylist="" try: addIconForPlaylist=args.get('addIconForPlaylist', '')[0] except: pass AddRemoveMyChannels=None try: AddRemoveMyChannels=args.get('AddRemoveMyChannels', None)[0] except: pass selectDefaultSource=None try: selectDefaultSource=args.get('selectDefaultSource', None)[0] except: pass HidChannel=None try: HidChannel=args.get('HideChannel', None)[0] except: pass print mode,pageNumber try: if not AddRemoveMyChannels==None: if AddRemoveMyChannels=="add": addToMyChannels(url) line1 = 'Channel has been added to My Channels list' time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) mode=-1 else: removeFromMyChannels(url) line1 = 'Channel has been removed from My Channels list' time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) mode=15 url="My Channels" print mode if not HidChannel==None: if HidChannel=="yes": setChannelSettings(url,'hidden',HidChannel) line1 = 'Channel has been hidden in categories' time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) mode=-1 else: setChannelSettings(url,'hidden','') line1 = 'Channel has been unhidden in categories' time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) mode=-1 url="" if not selectDefaultSource==None: default_source=selectDefaultSourcesForChannel(url) print 'v',default_source if not default_source==None: print 'saving settings',default_source setChannelSettings(url,'defaultsource',default_source) line1 = 'setting saved' time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) mode=-1 if mode==299: #add communutycats print 'delete cache' removeLoginFile(True,True) line1 = 'Login sessions cleared!' time = 2000 #in miliseconds xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,line1, time, __icon__)) xbmc.executebuiltin('Container.Update(plugin://plugin.video.shahidmbcnet)') mode=-1 if mode==None or url==None or len(url)<1: print "InAddTypes" checkAndRefresh() Addtypes() elif mode==2: print "Ent url is "+name,url AddChannels(url) elif mode==3 or mode==6: print "Ent url is "+url AddSeries(url,pageNumber) elif mode==4 or mode==7: print "Play url is "+url AddEnteries(url,pageNumber) elif mode==5 or mode==32: PlayShowLink(url) elif mode==8: print "Play url is "+url,mode ShowSettings(url) elif mode==24: print "Play url is "+url,mode LIVETvLogin(url) elif mode==9: print "Play url is "+url,mode AddStreams(); elif mode==10 or mode==11: print "Play url is "+url,mode PlayStream(url,name,mode); elif mode==14 or mode==26: #add communutycats print "Play url is "+url,mode checkAndRefresh() addCommunityCats(); elif mode==15: #add communutycats print "Play url is "+url,mode addCommunityChannels(url); elif mode==16: #add communutycats print "PlayCommunityStream Play url is "+url,mode PlayCommunityStream(url,name,mode); elif mode==17: #add communutycats print "RefreshResources Play url is "+url,mode RefreshResources(); elif mode==18: # print "youtube url is "+url,mode AddYoutubeSources(url) elif mode==19: # print "youtube url is "+url,mode AddYoutubeLanding(url) elif mode==20: #add communutycats print "youtube url is "+url,mode AddYoutubeVideosByChannelID(url,addIconForPlaylist); elif mode==21: #add communutycats print "play youtube url is "+url,mode PlayYoutube(url); elif mode==22: #add communutycats print "play youtube url is "+url,mode AddYoutubePlaylists(url); elif mode==23: #add communutycats print "play youtube url is "+url,mode AddYoutubeVideosByPlaylist(url); elif mode==25: #add communutycats print "play youtube url is "+url,mode ShowSources(url); elif mode==31: #add communutycats print "play youtube url is "+url,mode AddShahidMovies(url); elif mode==27: #add communutycats print "play youtube url is "+url,mode AddShahidVodMovietypes(); # elif mode==26: #add communutycats # print "play youtube url is "+url,mode # ShowSources(url); except: print 'somethingwrong' traceback.print_exc(file=sys.stdout) try: if (not mode==None) and mode>1: view_mode_id = get_view_mode_id('thumbnail') if view_mode_id is not None: print 'view_mode_id',view_mode_id xbmc.executebuiltin('Container.SetViewMode(%d)' % view_mode_id) except: pass if not ( mode==5 or mode==10 or mode==8 or mode==11 or mode==16 or mode==17 or mode==32): xbmcplugin.endOfDirectory(int(sys.argv[1]))
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 11709, 12, 26418, 12, 11709, 2718, 199, 646, 4011, 18, 12, 4078, 12, 13814, 12, 295, 199, 646, 24581, 199, 646, 11709, 9291, 199, 646, 2022, 199, 646, 5190, 199, 646, 747, 199, 646, 984, 199, 646, 26234, 199, 504, 17132, 492, 14562, 933, 368, 12341, 12, 17132, 12, 14562, 4118, 1282, 12, 8053, 12, 19617, 16725, 1558, 199, 893, 26, 523, 687, 14490, 2666, 50, 726, 13381, 50, 492, 7559, 523, 870, 480, 5720, 543, 14490, 14, 9464, 531, 199, 2590, 3545, 26, 199, 198, 893, 26, 17957, 327, 2018, 499, 14, 21, 17957, 492, 2748, 14, 9464, 14, 15325, 465, 7559, 17957, 870, 480, 5720, 543, 13139, 641, 2018, 499, 14, 21, 21425, 199, 198, 2590, 3545, 26, 17957, 862, 26, 507, 198, 3, 3293, 286, 15325, 3907, 507, 198, 646, 286, 15325, 465, 7559, 507, 198, 1361, 480, 5720, 543, 286, 15325, 531, 17957, 871, 3545, 26, 507, 198, 893, 26, 29294, 327, 3293, 13139, 3907, 29294, 492, 1819, 2350, 14, 15325, 465, 7559, 29294, 870, 480, 5720, 543, 13139, 531, 507, 198, 2590, 3545, 26, 29294, 870, 480, 4276, 370, 492, 13139, 687, 1263, 6040, 4192, 531, 199, 199, 646, 2022, 199, 199, 363, 9291, 363, 755, 275, 11709, 9291, 14, 19654, 342, 199, 363, 9291, 354, 363, 257, 275, 636, 9291, 4343, 362, 19654, 2354, 360, 354, 358, 199, 363, 4677, 363, 263, 275, 636, 9291, 4343, 362, 19654, 2354, 360, 4677, 358, 199, 9291, 63, 344, 275, 283, 2718, 14, 3722, 14, 4835, 18209, 887, 67, 846, 7, 199, 277, 19654, 275, 11709, 9291, 14, 19654, 8, 344, 29, 9291, 63, 344, 9, 199, 9291, 2042, 275, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 480, 515, 531, 199, 9291, 1023, 275, 21382, 9291, 14, 19654, 1252, 362, 19654, 2354, 480, 1023, 531, 199, 9291, 28922, 275, 747, 14, 515, 14, 904, 8, 9291, 2042, 2584, 4435, 15, 4782, 358, 199, 9387, 3296, 2042, 275, 747, 14, 515, 14, 904, 8, 9291, 2042, 2584, 4435, 358, 199, 9387, 3296, 2042, 275, 736, 14, 515, 14, 904, 8, 9387, 3296, 2042, 2584, 9387, 358, 199, 2913, 63, 515, 275, 221, 11709, 14, 5275, 2042, 8, 277, 19654, 14, 362, 19654, 2354, 360, 2913, 1333, 199, 199, 23527, 18209, 13665, 3817, 275, 23633, 3296, 2042, 23164, 23527, 18209, 54, 364, 7810, 14, 76, 14649, 7, 819, 199, 973, 633, 534, 1014, 921, 4835, 18209, 14, 887, 67, 14, 846, 7, 199, 28181, 534, 7730, 8076, 4323, 1968, 21, 77, 40, 23096, 37, 16, 14716, 1786, 39, 20, 9154, 46, 25542, 21, 75, 17, 37, 74, 17, 44, 49, 63, 19, 1092, 20, 7, 199, 199, 318, 664, 6756, 6417, 837, 199, 198, 82, 6756, 29, 973, 633, 199, 198, 3, 1074, 4260, 436, 1937, 340, 781, 1172, 4566, 5627, 12, 340, 1152, 12, 675, 626, 199, 198, 374, 4936, 6589, 29, 885, 7695, 46, 29, 277, 19654, 14, 30008, 8, 298, 374, 4936, 6589, 2, 776, 199, 198, 3280, 1476, 29, 885, 7695, 46, 29, 277, 19654, 14, 30008, 8, 298, 3280, 985, 2, 776, 199, 198, 4998, 5413, 29, 549, 258, 199, 198, 692, 365, 4936, 6589, 15596, 692, 2399, 440, 488, 507, 198, 3, 1361, 283, 374, 4936, 6589, 297, 374, 4936, 6589, 12, 3280, 1476, 507, 198, 692, 365, 4936, 6589, 11800, 2052, 582, 686, 198, 3, 1361, 283, 1405, 5223, 7, 686, 198, 4998, 5413, 29, 797, 20866, 198, 82, 6756, 29, 3280, 1476, 507, 198, 3, 2836, 26, 327, 1361, 283, 4936, 440, 4756, 7, 199, 198, 692, 4838, 5413, 26, 11083, 198, 1107, 519, 6756, 14, 1814, 360, 1014, 26, 1673, 2859, 10993, 199, 198, 2836, 26, 507, 198, 1107, 519, 6756, 31827, 1814, 360, 1014, 26, 1673, 2859, 10993, 28550, 8299, 199, 12058, 63, 31095, 275, 469, 272, 283, 8311, 356, 469, 267, 283, 16409, 14, 2190, 10836, 4894, 356, 6891, 12, 267, 283, 16409, 14, 3624, 265, 14, 889, 88, 356, 959, 2869, 12, 267, 283, 16409, 14, 2190, 10836, 4894, 13, 7870, 356, 6891, 12, 267, 283, 16409, 14, 74, 88, 18386, 356, 14589, 12, 267, 283, 16409, 14, 7073, 19, 13, 7952, 356, 13564, 12, 267, 283, 16409, 14, 345, 1038, 281, 356, 5238, 12, 267, 283, 16409, 14, 11184, 20976, 356, 6891, 12, 267, 283, 16409, 14, 23766, 75, 356, 13564, 12, 267, 283, 16409, 14, 31854, 356, 6891, 12, 267, 283, 16409, 14, 1515, 27292, 356, 13564, 12, 267, 283, 16409, 14, 11127, 656, 356, 12766, 12, 272, 1660, 199, 93, 199, 199, 318, 664, 63, 1345, 63, 632, 63, 344, 8, 2455, 63, 632, 304, 199, 198, 885, 63, 1345, 63, 632, 29, 277, 19654, 14, 30008, 8, 298, 1180, 3749, 1345, 632, 2, 776, 199, 198, 692, 849, 63, 1345, 63, 632, 389, 29679, 507, 198, 1345, 63, 632, 63, 1580, 275, 30359, 63, 31095, 14, 362, 8, 1345, 63, 632, 14, 2325, 1012, 507, 198, 692, 2455, 63, 632, 63, 1580, 26, 686, 198, 1107, 2455, 63, 632, 63, 1580, 14, 362, 8, 21382, 14, 362, 14194, 262, 3567, 1012, 199, 198, 2836, 26, 507, 198, 1107, 1109, 8, 885, 63, 1345, 63, 632, 9, 199, 198, 1107, 488, 199, 199, 318, 1050, 3834, 8, 354, 12, 633, 12, 4677, 1569, 304, 199, 198, 745, 29, 549, 199, 198, 19030, 29, 21382, 5885, 14, 24229, 8, 354, 12, 7016, 3491, 628, 2698, 9166, 14, 4524, 401, 10062, 3491, 29, 4677, 1569, 9, 199, 198, 19030, 14, 409, 2354, 8, 730, 628, 9166, 401, 2256, 14016, 3126, 298, 6888, 582, 536, 789, 776, 199, 198, 745, 29, 21382, 2718, 14, 525, 6231, 2081, 8, 2479, 29, 442, 8, 1274, 14, 3020, 59, 17, 2522, 633, 29, 633, 12, 513, 1053, 29, 19030, 9, 199, 198, 1107, 4112, 199, 199, 318, 1849, 21252, 8, 505, 275, 3260, 3164, 344, 275, 3260, 365, 26395, 275, 756, 304, 199, 198, 692, 3164, 344, 508, 283, 368, 356, 507, 198, 2326, 275, 283, 1665, 845, 66, 5783, 7, 199, 198, 4164, 3164, 344, 508, 283, 5601, 356, 507, 198, 2326, 275, 283, 1665, 69, 1401, 4893, 7, 199, 198, 4164 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 11709, 12, 26418, 12, 11709, 2718, 199, 646, 4011, 18, 12, 4078, 12, 13814, 12, 295, 199, 646, 24581, 199, 646, 11709, 9291, 199, 646, 2022, 199, 646, 5190, 199, 646, 747, 199, 646, 984, 199, 646, 26234, 199, 504, 17132, 492, 14562, 933, 368, 12341, 12, 17132, 12, 14562, 4118, 1282, 12, 8053, 12, 19617, 16725, 1558, 199, 893, 26, 523, 687, 14490, 2666, 50, 726, 13381, 50, 492, 7559, 523, 870, 480, 5720, 543, 14490, 14, 9464, 531, 199, 2590, 3545, 26, 199, 198, 893, 26, 17957, 327, 2018, 499, 14, 21, 17957, 492, 2748, 14, 9464, 14, 15325, 465, 7559, 17957, 870, 480, 5720, 543, 13139, 641, 2018, 499, 14, 21, 21425, 199, 198, 2590, 3545, 26, 17957, 862, 26, 507, 198, 3, 3293, 286, 15325, 3907, 507, 198, 646, 286, 15325, 465, 7559, 507, 198, 1361, 480, 5720, 543, 286, 15325, 531, 17957, 871, 3545, 26, 507, 198, 893, 26, 29294, 327, 3293, 13139, 3907, 29294, 492, 1819, 2350, 14, 15325, 465, 7559, 29294, 870, 480, 5720, 543, 13139, 531, 507, 198, 2590, 3545, 26, 29294, 870, 480, 4276, 370, 492, 13139, 687, 1263, 6040, 4192, 531, 199, 199, 646, 2022, 199, 199, 363, 9291, 363, 755, 275, 11709, 9291, 14, 19654, 342, 199, 363, 9291, 354, 363, 257, 275, 636, 9291, 4343, 362, 19654, 2354, 360, 354, 358, 199, 363, 4677, 363, 263, 275, 636, 9291, 4343, 362, 19654, 2354, 360, 4677, 358, 199, 9291, 63, 344, 275, 283, 2718, 14, 3722, 14, 4835, 18209, 887, 67, 846, 7, 199, 277, 19654, 275, 11709, 9291, 14, 19654, 8, 344, 29, 9291, 63, 344, 9, 199, 9291, 2042, 275, 11709, 9291, 14, 19654, 1252, 362, 19654, 2354, 480, 515, 531, 199, 9291, 1023, 275, 21382, 9291, 14, 19654, 1252, 362, 19654, 2354, 480, 1023, 531, 199, 9291, 28922, 275, 747, 14, 515, 14, 904, 8, 9291, 2042, 2584, 4435, 15, 4782, 358, 199, 9387, 3296, 2042, 275, 747, 14, 515, 14, 904, 8, 9291, 2042, 2584, 4435, 358, 199, 9387, 3296, 2042, 275, 736, 14, 515, 14, 904, 8, 9387, 3296, 2042, 2584, 9387, 358, 199, 2913, 63, 515, 275, 221, 11709, 14, 5275, 2042, 8, 277, 19654, 14, 362, 19654, 2354, 360, 2913, 1333, 199, 199, 23527, 18209, 13665, 3817, 275, 23633, 3296, 2042, 23164, 23527, 18209, 54, 364, 7810, 14, 76, 14649, 7, 819, 199, 973, 633, 534, 1014, 921, 4835, 18209, 14, 887, 67, 14, 846, 7, 199, 28181, 534, 7730, 8076, 4323, 1968, 21, 77, 40, 23096, 37, 16, 14716, 1786, 39, 20, 9154, 46, 25542, 21, 75, 17, 37, 74, 17, 44, 49, 63, 19, 1092, 20, 7, 199, 199, 318, 664, 6756, 6417, 837, 199, 198, 82, 6756, 29, 973, 633, 199, 198, 3, 1074, 4260, 436, 1937, 340, 781, 1172, 4566, 5627, 12, 340, 1152, 12, 675, 626, 199, 198, 374, 4936, 6589, 29, 885, 7695, 46, 29, 277, 19654, 14, 30008, 8, 298, 374, 4936, 6589, 2, 776, 199, 198, 3280, 1476, 29, 885, 7695, 46, 29, 277, 19654, 14, 30008, 8, 298, 3280, 985, 2, 776, 199, 198, 4998, 5413, 29, 549, 258, 199, 198, 692, 365, 4936, 6589, 15596, 692, 2399, 440, 488, 507, 198, 3, 1361, 283, 374, 4936, 6589, 297, 374, 4936, 6589, 12, 3280, 1476, 507, 198, 692, 365, 4936, 6589, 11800, 2052, 582, 686, 198, 3, 1361, 283, 1405, 5223, 7, 686, 198, 4998, 5413, 29, 797, 20866, 198, 82, 6756, 29, 3280, 1476, 507, 198, 3, 2836, 26, 327, 1361, 283, 4936, 440, 4756, 7, 199, 198, 692, 4838, 5413, 26, 11083, 198, 1107, 519, 6756, 14, 1814, 360, 1014, 26, 1673, 2859, 10993, 199, 198, 2836, 26, 507, 198, 1107, 519, 6756, 31827, 1814, 360, 1014, 26, 1673, 2859, 10993, 28550, 8299, 199, 12058, 63, 31095, 275, 469, 272, 283, 8311, 356, 469, 267, 283, 16409, 14, 2190, 10836, 4894, 356, 6891, 12, 267, 283, 16409, 14, 3624, 265, 14, 889, 88, 356, 959, 2869, 12, 267, 283, 16409, 14, 2190, 10836, 4894, 13, 7870, 356, 6891, 12, 267, 283, 16409, 14, 74, 88, 18386, 356, 14589, 12, 267, 283, 16409, 14, 7073, 19, 13, 7952, 356, 13564, 12, 267, 283, 16409, 14, 345, 1038, 281, 356, 5238, 12, 267, 283, 16409, 14, 11184, 20976, 356, 6891, 12, 267, 283, 16409, 14, 23766, 75, 356, 13564, 12, 267, 283, 16409, 14, 31854, 356, 6891, 12, 267, 283, 16409, 14, 1515, 27292, 356, 13564, 12, 267, 283, 16409, 14, 11127, 656, 356, 12766, 12, 272, 1660, 199, 93, 199, 199, 318, 664, 63, 1345, 63, 632, 63, 344, 8, 2455, 63, 632, 304, 199, 198, 885, 63, 1345, 63, 632, 29, 277, 19654, 14, 30008, 8, 298, 1180, 3749, 1345, 632, 2, 776, 199, 198, 692, 849, 63, 1345, 63, 632, 389, 29679, 507, 198, 1345, 63, 632, 63, 1580, 275, 30359, 63, 31095, 14, 362, 8, 1345, 63, 632, 14, 2325, 1012, 507, 198, 692, 2455, 63, 632, 63, 1580, 26, 686, 198, 1107, 2455, 63, 632, 63, 1580, 14, 362, 8, 21382, 14, 362, 14194, 262, 3567, 1012, 199, 198, 2836, 26, 507, 198, 1107, 1109, 8, 885, 63, 1345, 63, 632, 9, 199, 198, 1107, 488, 199, 199, 318, 1050, 3834, 8, 354, 12, 633, 12, 4677, 1569, 304, 199, 198, 745, 29, 549, 199, 198, 19030, 29, 21382, 5885, 14, 24229, 8, 354, 12, 7016, 3491, 628, 2698, 9166, 14, 4524, 401, 10062, 3491, 29, 4677, 1569, 9, 199, 198, 19030, 14, 409, 2354, 8, 730, 628, 9166, 401, 2256, 14016, 3126, 298, 6888, 582, 536, 789, 776, 199, 198, 745, 29, 21382, 2718, 14, 525, 6231, 2081, 8, 2479, 29, 442, 8, 1274, 14, 3020, 59, 17, 2522, 633, 29, 633, 12, 513, 1053, 29, 19030, 9, 199, 198, 1107, 4112, 199, 199, 318, 1849, 21252, 8, 505, 275, 3260, 3164, 344, 275, 3260, 365, 26395, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
FlaPer87/django-nonrel
django/core/cache/backends/base.py
20
3810
"Base Cache class." from django.core.exceptions import ImproperlyConfigured class InvalidCacheBackendError(ImproperlyConfigured): pass class BaseCache(object): def __init__(self, params): timeout = params.get('timeout', 300) try: timeout = int(timeout) except (ValueError, TypeError): timeout = 300 self.default_timeout = timeout def add(self, key, value, timeout=None): """ Set a value in the cache if the key does not already exist. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. Returns True if the value was stored, False otherwise. """ raise NotImplementedError def get(self, key, default=None): """ Fetch a given key from the cache. If the key does not exist, return default, which itself defaults to None. """ raise NotImplementedError def set(self, key, value, timeout=None): """ Set a value in the cache. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. """ raise NotImplementedError def delete(self, key): """ Delete a key from the cache, failing silently. """ raise NotImplementedError def get_many(self, keys): """ Fetch a bunch of keys from the cache. For certain backends (memcached, pgsql) this can be *much* faster when fetching multiple values. Returns a dict mapping each key in keys to its value. If the given key is missing, it will be missing from the response dict. """ d = {} for k in keys: val = self.get(k) if val is not None: d[k] = val return d def has_key(self, key): """ Returns True if the key is in the cache and has not expired. """ return self.get(key) is not None def incr(self, key, delta=1): """ Add delta to value in the cache. If the key does not exist, raise a ValueError exception. """ if key not in self: raise ValueError("Key '%s' not found" % key) new_value = self.get(key) + delta self.set(key, new_value) return new_value def decr(self, key, delta=1): """ Subtract delta from value in the cache. If the key does not exist, raise a ValueError exception. """ return self.incr(key, -delta) def __contains__(self, key): """ Returns True if the key is in the cache and has not expired. """ # This is a separate method, rather than just a copy of has_key(), # so that it always has the same functionality as has_key(), even # if a subclass overrides it. return self.has_key(key) def set_many(self, data, timeout=None): """ Set a bunch of values in the cache at once from a dict of key/value pairs. For certain backends (memcached), this is much more efficient than calling set() multiple times. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. """ for key, value in data.items(): self.set(key, value, timeout) def delete_many(self, keys): """ Set a bunch of values in the cache at once. For certain backends (memcached), this is much more efficient than calling delete() multiple times. """ for key in keys: self.delete(key) def clear(self): """Remove *all* values from the cache at once.""" raise NotImplementedError
bsd-3-clause
[ 2, 1563, 11977, 1021, 2122, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 199, 533, 6378, 4437, 8447, 547, 8, 8499, 10951, 304, 272, 986, 199, 199, 533, 3523, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 2653, 275, 1862, 14, 362, 360, 2593, 297, 9601, 9, 267, 862, 26, 288, 2653, 275, 1109, 8, 2593, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 2653, 275, 9601, 267, 291, 14, 885, 63, 2593, 275, 2653, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 340, 314, 790, 1630, 440, 2575, 2187, 14, 982, 267, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 398, 1803, 715, 340, 314, 574, 1990, 5489, 12, 756, 4257, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 408, 267, 16347, 282, 1627, 790, 687, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 372, 267, 849, 12, 1314, 6337, 4243, 370, 488, 14, 267, 408, 267, 746, 4279, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 14, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 267, 1202, 367, 314, 790, 27, 4257, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 746, 4279, 339, 347, 3145, 8, 277, 12, 790, 304, 267, 408, 267, 8496, 282, 790, 687, 314, 2581, 12, 18648, 18030, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 63, 3479, 8, 277, 12, 2883, 304, 267, 408, 267, 16347, 282, 22219, 402, 2883, 687, 314, 2581, 14, 2104, 9842, 14745, 334, 32567, 12, 267, 299, 458, 1710, 9, 642, 883, 506, 627, 77, 2133, 10, 12930, 1380, 21239, 3663, 1338, 14, 398, 1803, 282, 1211, 4412, 1924, 790, 315, 2883, 370, 2399, 574, 14, 982, 314, 1627, 267, 790, 365, 4124, 12, 652, 911, 506, 4124, 687, 314, 1177, 1211, 14, 267, 408, 267, 366, 275, 1052, 267, 367, 1022, 315, 2883, 26, 288, 1139, 275, 291, 14, 362, 8, 75, 9, 288, 340, 1139, 365, 440, 488, 26, 355, 366, 59, 75, 61, 275, 1139, 267, 372, 366, 339, 347, 965, 63, 498, 8, 277, 12, 790, 304, 267, 408, 267, 1803, 715, 340, 314, 790, 365, 315, 314, 2581, 436, 965, 440, 14721, 14, 267, 408, 267, 372, 291, 14, 362, 8, 498, 9, 365, 440, 488, 339, 347, 315, 1556, 8, 277, 12, 790, 12, 5762, 29, 17, 304, 267, 408, 267, 2654, 5762, 370, 574, 315, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 746, 282, 267, 1722, 1919, 14, 267, 408, 267, 340, 790, 440, 315, 291, 26, 288, 746, 1722, 480, 1197, 1543, 83, 7, 440, 1911, 2, 450, 790, 9, 267, 892, 63, 585, 275, 291, 14, 362, 8, 498, 9, 435, 5762, 267, 291, 14, 409, 8, 498, 12, 892, 63, 585, 9, 267, 372, 892, 63, 585, 339, 347, 477, 1556, 8, 277, 12, 790, 12, 5762, 29, 17, 304, 267, 408, 267, 4804, 6908, 5762, 687, 574, 315, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 746, 267, 282, 1722, 1919, 14, 267, 408, 267, 372, 291, 14, 19362, 8, 498, 12, 446, 3136, 9, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 408, 267, 1803, 715, 340, 314, 790, 365, 315, 314, 2581, 436, 965, 440, 14721, 14, 267, 408, 267, 327, 961, 365, 282, 7396, 1083, 12, 7830, 2419, 2951, 282, 1331, 402, 965, 63, 498, 1062, 267, 327, 880, 626, 652, 3544, 965, 314, 2011, 9330, 465, 965, 63, 498, 1062, 2755, 267, 327, 340, 282, 5516, 10580, 652, 14, 267, 372, 291, 14, 1989, 63, 498, 8, 498, 9, 339, 347, 663, 63, 3479, 8, 277, 12, 666, 12, 2653, 29, 403, 304, 267, 408, 267, 2494, 282, 22219, 402, 1338, 315, 314, 2581, 737, 5403, 687, 282, 1211, 402, 790, 15, 585, 267, 6342, 14, 221, 2104, 9842, 14745, 334, 32567, 395, 642, 365, 8298, 1655, 13402, 267, 2419, 6358, 663, 342, 3663, 5431, 14, 398, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 367, 790, 12, 574, 315, 666, 14, 1744, 837, 288, 291, 14, 409, 8, 498, 12, 574, 12, 2653, 9, 339, 347, 3145, 63, 3479, 8, 277, 12, 2883, 304, 267, 408, 267, 2494, 282, 22219, 402, 1338, 315, 314, 2581, 737, 5403, 14, 221, 2104, 9842, 14745, 267, 334, 32567, 395, 642, 365, 8298, 1655, 13402, 2419, 6358, 3145, 342, 3663, 267, 5431, 14, 267, 408, 267, 367, 790, 315, 2883, 26, 288, 291, 14, 1807, 8, 498, 9, 339, 347, 5436, 8, 277, 304, 267, 408, 5587, 627, 452, 10, 1338, 687, 314, 2581, 737, 5403, 1041, 267, 746, 4279, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1563, 11977, 1021, 2122, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 199, 533, 6378, 4437, 8447, 547, 8, 8499, 10951, 304, 272, 986, 199, 199, 533, 3523, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 2653, 275, 1862, 14, 362, 360, 2593, 297, 9601, 9, 267, 862, 26, 288, 2653, 275, 1109, 8, 2593, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 2653, 275, 9601, 267, 291, 14, 885, 63, 2593, 275, 2653, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 340, 314, 790, 1630, 440, 2575, 2187, 14, 982, 267, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 398, 1803, 715, 340, 314, 574, 1990, 5489, 12, 756, 4257, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 408, 267, 16347, 282, 1627, 790, 687, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 372, 267, 849, 12, 1314, 6337, 4243, 370, 488, 14, 267, 408, 267, 746, 4279, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 14, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 267, 1202, 367, 314, 790, 27, 4257, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 746, 4279, 339, 347, 3145, 8, 277, 12, 790, 304, 267, 408, 267, 8496, 282, 790, 687, 314, 2581, 12, 18648, 18030, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 63, 3479, 8, 277, 12, 2883, 304, 267, 408, 267, 16347, 282, 22219, 402, 2883, 687, 314, 2581, 14, 2104, 9842, 14745, 334, 32567, 12, 267, 299, 458, 1710, 9, 642, 883, 506, 627, 77, 2133, 10, 12930, 1380, 21239, 3663, 1338, 14, 398, 1803, 282, 1211, 4412, 1924, 790, 315, 2883, 370, 2399, 574, 14, 982, 314, 1627, 267, 790, 365, 4124, 12, 652, 911, 506, 4124, 687, 314, 1177, 1211, 14, 267, 408, 267, 366, 275, 1052, 267, 367, 1022, 315, 2883, 26, 288, 1139, 275, 291, 14, 362, 8, 75, 9, 288, 340, 1139, 365, 440, 488, 26, 355, 366, 59, 75, 61, 275, 1139, 267, 372, 366, 339, 347, 965, 63, 498, 8, 277, 12, 790, 304, 267, 408, 267, 1803, 715, 340, 314, 790, 365, 315, 314, 2581, 436, 965, 440, 14721, 14, 267, 408, 267, 372, 291, 14, 362, 8, 498, 9, 365, 440, 488, 339, 347, 315, 1556, 8, 277, 12, 790, 12, 5762, 29, 17, 304, 267, 408, 267, 2654, 5762, 370, 574, 315, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 746, 282, 267, 1722, 1919, 14, 267, 408, 267, 340, 790, 440, 315, 291, 26, 288, 746, 1722, 480, 1197, 1543, 83, 7, 440, 1911, 2, 450, 790, 9, 267, 892, 63, 585, 275, 291, 14, 362, 8, 498, 9, 435, 5762, 267, 291, 14, 409, 8, 498, 12, 892, 63, 585, 9, 267, 372, 892, 63, 585, 339, 347, 477, 1556, 8, 277, 12, 790, 12, 5762, 29, 17, 304, 267, 408, 267, 4804, 6908, 5762, 687, 574, 315, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 746, 267, 282, 1722, 1919, 14, 267, 408, 267, 372, 291, 14, 19362, 8, 498, 12, 446, 3136, 9, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 408, 267, 1803, 715, 340, 314, 790, 365, 315, 314, 2581, 436, 965, 440, 14721, 14, 267, 408, 267, 327, 961, 365, 282, 7396, 1083, 12, 7830, 2419, 2951, 282, 1331, 402, 965, 63, 498, 1062, 267, 327, 880, 626, 652, 3544, 965, 314, 2011, 9330, 465, 965, 63, 498, 1062, 2755, 267, 327, 340, 282, 5516, 10580, 652, 14, 267, 372, 291, 14, 1989, 63, 498, 8, 498, 9, 339, 347, 663, 63, 3479, 8, 277, 12, 666, 12, 2653, 29, 403, 304, 267, 408, 267, 2494, 282, 22219, 402, 1338, 315, 314, 2581, 737, 5403, 687, 282, 1211, 402, 790, 15, 585, 267, 6342, 14, 221, 2104, 9842, 14745, 334, 32567, 395, 642, 365, 8298, 1655, 13402, 267, 2419, 6358, 663, 342, 3663, 5431, 14, 398, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 367, 790, 12, 574, 315, 666, 14, 1744, 837, 288, 291, 14, 409, 8, 498, 12, 574, 12, 2653, 9, 339, 347, 3145, 63, 3479, 8, 277, 12, 2883, 304, 267, 408, 267, 2494, 282, 22219, 402, 1338, 315, 314, 2581, 737, 5403, 14, 221, 2104, 9842, 14745, 267, 334, 32567, 395, 642, 365, 8298, 1655, 13402, 2419, 6358, 3145, 342, 3663, 267, 5431, 14, 267, 408, 267, 367, 790, 315, 2883, 26, 288, 291, 14, 1807, 8, 498, 9, 339, 347, 5436, 8, 277, 304, 267, 408, 5587, 627, 452, 10, 1338, 687, 314, 2581, 737, 5403, 1041, 267, 746, 4279, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1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/YourVoiceAlarmBackend
lib/werkzeug/contrib/lint.py
318
12282
# -*- coding: utf-8 -*- """ werkzeug.contrib.lint ~~~~~~~~~~~~~~~~~~~~~ .. versionadded:: 0.5 This module provides a middleware that performs sanity checks of the WSGI application. It checks that :pep:`333` is properly implemented and warns on some common HTTP errors such as non-empty responses for 304 status codes. This module provides a middleware, the :class:`LintMiddleware`. Wrap your application with it and it will warn about common problems with WSGI and HTTP while your application is running. It's strongly recommended to use it during development. :copyright: (c) 2013 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from urlparse import urlparse from warnings import warn from werkzeug.datastructures import Headers from werkzeug.http import is_entity_header from werkzeug.wsgi import FileWrapper from werkzeug._compat import string_types class WSGIWarning(Warning): """Warning class for WSGI warnings.""" class HTTPWarning(Warning): """Warning class for HTTP warnings.""" def check_string(context, obj, stacklevel=3): if type(obj) is not str: warn(WSGIWarning('%s requires bytestrings, got %s' % (context, obj.__class__.__name__))) class InputStream(object): def __init__(self, stream): self._stream = stream def read(self, *args): if len(args) == 0: warn(WSGIWarning('wsgi does not guarantee an EOF marker on the ' 'input stream, thus making calls to ' 'wsgi.input.read() unsafe. Conforming servers ' 'may never return from this call.'), stacklevel=2) elif len(args) != 1: warn(WSGIWarning('too many parameters passed to wsgi.input.read()'), stacklevel=2) return self._stream.read(*args) def readline(self, *args): if len(args) == 0: warn(WSGIWarning('Calls to wsgi.input.readline() without arguments' ' are unsafe. Use wsgi.input.read() instead.'), stacklevel=2) elif len(args) == 1: warn(WSGIWarning('wsgi.input.readline() was called with a size hint. ' 'WSGI does not support this, although it\'s available ' 'on all major servers.'), stacklevel=2) else: raise TypeError('too many arguments passed to wsgi.input.readline()') return self._stream.readline(*args) def __iter__(self): try: return iter(self._stream) except TypeError: warn(WSGIWarning('wsgi.input is not iterable.'), stacklevel=2) return iter(()) def close(self): warn(WSGIWarning('application closed the input stream!'), stacklevel=2) self._stream.close() class ErrorStream(object): def __init__(self, stream): self._stream = stream def write(self, s): check_string('wsgi.error.write()', s) self._stream.write(s) def flush(self): self._stream.flush() def writelines(self, seq): for line in seq: self.write(seq) def close(self): warn(WSGIWarning('application closed the error stream!'), stacklevel=2) self._stream.close() class GuardedWrite(object): def __init__(self, write, chunks): self._write = write self._chunks = chunks def __call__(self, s): check_string('write()', s) self._write.write(s) self._chunks.append(len(s)) class GuardedIterator(object): def __init__(self, iterator, headers_set, chunks): self._iterator = iterator self._next = iter(iterator).next self.closed = False self.headers_set = headers_set self.chunks = chunks def __iter__(self): return self def next(self): if self.closed: warn(WSGIWarning('iterated over closed app_iter'), stacklevel=2) rv = self._next() if not self.headers_set: warn(WSGIWarning('Application returned before it ' 'started the response'), stacklevel=2) check_string('application iterator items', rv) self.chunks.append(len(rv)) return rv def close(self): self.closed = True if hasattr(self._iterator, 'close'): self._iterator.close() if self.headers_set: status_code, headers = self.headers_set bytes_sent = sum(self.chunks) content_length = headers.get('content-length', type=int) if status_code == 304: for key, value in headers: key = key.lower() if key not in ('expires', 'content-location') and \ is_entity_header(key): warn(HTTPWarning('entity header %r found in 304 ' 'response' % key)) if bytes_sent: warn(HTTPWarning('304 responses must not have a body')) elif 100 <= status_code < 200 or status_code == 204: if content_length != 0: warn(HTTPWarning('%r responses must have an empty ' 'content length') % status_code) if bytes_sent: warn(HTTPWarning('%r responses must not have a body' % status_code)) elif content_length is not None and content_length != bytes_sent: warn(WSGIWarning('Content-Length and the number of bytes ' 'sent to the client do not match.')) def __del__(self): if not self.closed: try: warn(WSGIWarning('Iterator was garbage collected before ' 'it was closed.')) except Exception: pass class LintMiddleware(object): """This middleware wraps an application and warns on common errors. Among other thing it currently checks for the following problems: - invalid status codes - non-bytestrings sent to the WSGI server - strings returned from the WSGI application - non-empty conditional responses - unquoted etags - relative URLs in the Location header - unsafe calls to wsgi.input - unclosed iterators Detected errors are emitted using the standard Python :mod:`warnings` system and usually end up on :data:`stderr`. :: from werkzeug.contrib.lint import LintMiddleware app = LintMiddleware(app) :param app: the application to wrap """ def __init__(self, app): self.app = app def check_environ(self, environ): if type(environ) is not dict: warn(WSGIWarning('WSGI environment is not a standard python dict.'), stacklevel=4) for key in ('REQUEST_METHOD', 'SERVER_NAME', 'SERVER_PORT', 'wsgi.version', 'wsgi.input', 'wsgi.errors', 'wsgi.multithread', 'wsgi.multiprocess', 'wsgi.run_once'): if key not in environ: warn(WSGIWarning('required environment key %r not found' % key), stacklevel=3) if environ['wsgi.version'] != (1, 0): warn(WSGIWarning('environ is not a WSGI 1.0 environ'), stacklevel=3) script_name = environ.get('SCRIPT_NAME', '') if script_name and script_name[:1] != '/': warn(WSGIWarning('SCRIPT_NAME does not start with a slash: %r' % script_name), stacklevel=3) path_info = environ.get('PATH_INFO', '') if path_info[:1] != '/': warn(WSGIWarning('PATH_INFO does not start with a slash: %r' % path_info), stacklevel=3) def check_start_response(self, status, headers, exc_info): check_string('status', status) status_code = status.split(None, 1)[0] if len(status_code) != 3 or not status_code.isdigit(): warn(WSGIWarning('Status code must be three digits'), stacklevel=3) if len(status) < 4 or status[3] != ' ': warn(WSGIWarning('Invalid value for status %r. Valid ' 'status strings are three digits, a space ' 'and a status explanation'), stacklevel=3) status_code = int(status_code) if status_code < 100: warn(WSGIWarning('status code < 100 detected'), stacklevel=3) if type(headers) is not list: warn(WSGIWarning('header list is not a list'), stacklevel=3) for item in headers: if type(item) is not tuple or len(item) != 2: warn(WSGIWarning('Headers must tuple 2-item tuples'), stacklevel=3) name, value = item if type(name) is not str or type(value) is not str: warn(WSGIWarning('header items must be strings'), stacklevel=3) if name.lower() == 'status': warn(WSGIWarning('The status header is not supported due to ' 'conflicts with the CGI spec.'), stacklevel=3) if exc_info is not None and not isinstance(exc_info, tuple): warn(WSGIWarning('invalid value for exc_info'), stacklevel=3) headers = Headers(headers) self.check_headers(headers) return status_code, headers def check_headers(self, headers): etag = headers.get('etag') if etag is not None: if etag.startswith('w/'): etag = etag[2:] if not (etag[:1] == etag[-1:] == '"'): warn(HTTPWarning('unquoted etag emitted.'), stacklevel=4) location = headers.get('location') if location is not None: if not urlparse(location).netloc: warn(HTTPWarning('absolute URLs required for location header'), stacklevel=4) def check_iterator(self, app_iter): if isinstance(app_iter, string_types): warn(WSGIWarning('application returned string. Response will ' 'send character for character to the client ' 'which will kill the performance. Return a ' 'list or iterable instead.'), stacklevel=3) def __call__(self, *args, **kwargs): if len(args) != 2: warn(WSGIWarning('Two arguments to WSGI app required'), stacklevel=2) if kwargs: warn(WSGIWarning('No keyword arguments to WSGI app allowed'), stacklevel=2) environ, start_response = args self.check_environ(environ) environ['wsgi.input'] = InputStream(environ['wsgi.input']) environ['wsgi.errors'] = ErrorStream(environ['wsgi.errors']) # hook our own file wrapper in so that applications will always # iterate to the end and we can check the content length environ['wsgi.file_wrapper'] = FileWrapper headers_set = [] chunks = [] def checking_start_response(*args, **kwargs): if len(args) not in (2, 3): warn(WSGIWarning('Invalid number of arguments: %s, expected ' '2 or 3' % len(args), stacklevel=2)) if kwargs: warn(WSGIWarning('no keyword arguments allowed.')) status, headers = args[:2] if len(args) == 3: exc_info = args[2] else: exc_info = None headers_set[:] = self.check_start_response(status, headers, exc_info) return GuardedWrite(start_response(status, headers, exc_info), chunks) app_iter = self.app(environ, checking_start_response) self.check_iterator(app_iter) return GuardedIterator(app_iter, headers_set, chunks)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 2828, 14, 3854, 272, 18294, 2878, 94, 339, 2508, 7445, 447, 378, 14, 21, 339, 961, 859, 6571, 282, 10816, 626, 18628, 16740, 5920, 402, 314, 9279, 272, 4223, 14, 221, 2779, 5920, 626, 520, 12636, 1705, 11769, 64, 365, 7684, 6366, 436, 3429, 561, 272, 641, 2005, 2863, 3101, 2552, 4066, 465, 2222, 13, 1667, 9320, 367, 20398, 2004, 272, 9479, 14, 339, 961, 859, 6571, 282, 10816, 12, 314, 520, 533, 1705, 44, 442, 6608, 2313, 221, 20322, 2195, 272, 4223, 543, 652, 436, 652, 911, 7987, 3595, 2863, 8826, 543, 9279, 436, 272, 3101, 1830, 2195, 4223, 365, 3879, 14, 339, 2779, 1159, 30390, 14318, 370, 675, 652, 5309, 16367, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 7097, 492, 7097, 199, 504, 3598, 492, 7987, 199, 199, 504, 10380, 14, 23004, 492, 21391, 199, 504, 10380, 14, 1014, 492, 365, 63, 4502, 63, 1291, 199, 504, 10380, 14, 6508, 492, 3814, 4590, 199, 504, 10380, 423, 5819, 492, 1059, 63, 1313, 421, 199, 533, 9279, 3849, 8, 3849, 304, 272, 408, 3849, 1021, 367, 9279, 3598, 1041, 421, 199, 533, 3101, 3849, 8, 3849, 304, 272, 408, 3849, 1021, 367, 3101, 3598, 1041, 421, 199, 318, 1104, 63, 875, 8, 1100, 12, 1559, 12, 13232, 29, 19, 304, 272, 340, 730, 8, 1113, 9, 365, 440, 620, 26, 267, 7987, 8, 16828, 3849, 3508, 83, 5074, 18792, 25182, 12, 4788, 450, 83, 7, 450, 288, 334, 1100, 12, 1559, 855, 533, 4914, 354, 29658, 421, 199, 533, 6924, 3296, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 304, 267, 291, 423, 1745, 275, 2547, 339, 347, 1586, 8, 277, 12, 627, 589, 304, 267, 340, 822, 8, 589, 9, 508, 378, 26, 288, 7987, 8, 16828, 3849, 360, 6508, 1630, 440, 24197, 376, 9027, 3608, 641, 314, 283, 2490, 283, 1210, 2547, 12, 12850, 10663, 4882, 370, 283, 2490, 283, 6508, 14, 1210, 14, 739, 342, 19293, 14, 221, 1448, 964, 316, 8037, 283, 2490, 283, 7551, 7078, 372, 687, 642, 1240, 8038, 326, 13232, 29, 18, 9, 267, 916, 822, 8, 589, 9, 1137, 413, 26, 288, 7987, 8, 16828, 3849, 360, 7354, 5002, 2633, 3032, 370, 12464, 14, 1210, 14, 739, 21898, 326, 13232, 29, 18, 9, 267, 372, 291, 423, 1745, 14, 739, 2031, 589, 9, 339, 347, 14441, 8, 277, 12, 627, 589, 304, 267, 340, 822, 8, 589, 9, 508, 378, 26, 288, 7987, 8, 16828, 3849, 360, 18287, 370, 12464, 14, 1210, 14, 6407, 342, 1928, 2368, 7, 2490, 283, 787, 19293, 14, 221, 3645, 12464, 14, 1210, 14, 739, 342, 3140, 8038, 326, 13232, 29, 18, 9, 267, 916, 822, 8, 589, 9, 508, 413, 26, 288, 7987, 8, 16828, 3849, 360, 6508, 14, 1210, 14, 6407, 342, 1990, 2797, 543, 282, 1568, 8328, 14, 283, 2490, 283, 16828, 1630, 440, 2291, 642, 12, 22160, 652, 3985, 83, 2808, 283, 2490, 283, 265, 1006, 12160, 8037, 8038, 326, 13232, 29, 18, 9, 267, 587, 26, 288, 746, 3146, 360, 7354, 5002, 2368, 3032, 370, 12464, 14, 1210, 14, 6407, 19004, 267, 372, 291, 423, 1745, 14, 6407, 2031, 589, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 862, 26, 288, 372, 2740, 8, 277, 423, 1745, 9, 267, 871, 3146, 26, 288, 7987, 8, 16828, 3849, 360, 6508, 14, 1210, 365, 440, 6076, 8038, 13232, 29, 18, 9, 288, 372, 2740, 30812, 339, 347, 4002, 8, 277, 304, 267, 7987, 8, 16828, 3849, 360, 3578, 6876, 314, 1324, 2547, 15659, 1467, 13232, 29, 18, 9, 267, 291, 423, 1745, 14, 1600, 342, 421, 199, 533, 4520, 3296, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 304, 267, 291, 423, 1745, 275, 2547, 339, 347, 2218, 8, 277, 12, 308, 304, 267, 1104, 63, 875, 360, 6508, 14, 705, 14, 952, 19633, 308, 9, 267, 291, 423, 1745, 14, 952, 8, 83, 9, 339, 347, 8976, 8, 277, 304, 267, 291, 423, 1745, 14, 4939, 342, 339, 347, 2218, 1278, 8, 277, 12, 5412, 304, 267, 367, 1004, 315, 5412, 26, 288, 291, 14, 952, 8, 3610, 9, 339, 347, 4002, 8, 277, 304, 267, 7987, 8, 16828, 3849, 360, 3578, 6876, 314, 1125, 2547, 15659, 1467, 13232, 29, 18, 9, 267, 291, 423, 1745, 14, 1600, 342, 421, 199, 533, 12436, 12910, 3534, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2218, 12, 8291, 304, 267, 291, 423, 952, 275, 2218, 267, 291, 423, 10660, 275, 8291, 339, 347, 636, 1250, 721, 277, 12, 308, 304, 267, 1104, 63, 875, 360, 952, 19633, 308, 9, 267, 291, 423, 952, 14, 952, 8, 83, 9, 267, 291, 423, 10660, 14, 740, 8, 552, 8, 83, 430, 421, 199, 533, 12436, 12910, 3585, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 6122, 12, 2323, 63, 409, 12, 8291, 304, 267, 291, 423, 5778, 275, 6122, 267, 291, 423, 2184, 275, 2740, 8, 5778, 680, 2184, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 2139, 63, 409, 275, 2323, 63, 409, 267, 291, 14, 10660, 275, 8291, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 339, 347, 2163, 8, 277, 304, 267, 340, 291, 14, 5938, 26, 288, 7987, 8, 16828, 3849, 360, 1661, 972, 1806, 6876, 1145, 63, 1661, 659, 326, 13232, 29, 18, 9, 267, 4336, 275, 291, 423, 2184, 342, 267, 340, 440, 291, 14, 2139, 63, 409, 26, 288, 7987, 8, 16828, 3849, 360, 5039, 2138, 2544, 652, 283, 2490, 283, 8924, 314, 1177, 659, 13232, 29, 18, 9, 267, 1104, 63, 875, 360, 3578, 6122, 2974, 297, 4336, 9, 267, 291, 14, 10660, 14, 740, 8, 552, 8, 6310, 430, 267, 372, 4336, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 5938, 275, 715, 267, 340, 2688, 8, 277, 423, 5778, 12, 283, 1600, 735, 288, 291, 423, 5778, 14, 1600, 342, 398, 340, 291 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 2828, 14, 3854, 272, 18294, 2878, 94, 339, 2508, 7445, 447, 378, 14, 21, 339, 961, 859, 6571, 282, 10816, 626, 18628, 16740, 5920, 402, 314, 9279, 272, 4223, 14, 221, 2779, 5920, 626, 520, 12636, 1705, 11769, 64, 365, 7684, 6366, 436, 3429, 561, 272, 641, 2005, 2863, 3101, 2552, 4066, 465, 2222, 13, 1667, 9320, 367, 20398, 2004, 272, 9479, 14, 339, 961, 859, 6571, 282, 10816, 12, 314, 520, 533, 1705, 44, 442, 6608, 2313, 221, 20322, 2195, 272, 4223, 543, 652, 436, 652, 911, 7987, 3595, 2863, 8826, 543, 9279, 436, 272, 3101, 1830, 2195, 4223, 365, 3879, 14, 339, 2779, 1159, 30390, 14318, 370, 675, 652, 5309, 16367, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 7097, 492, 7097, 199, 504, 3598, 492, 7987, 199, 199, 504, 10380, 14, 23004, 492, 21391, 199, 504, 10380, 14, 1014, 492, 365, 63, 4502, 63, 1291, 199, 504, 10380, 14, 6508, 492, 3814, 4590, 199, 504, 10380, 423, 5819, 492, 1059, 63, 1313, 421, 199, 533, 9279, 3849, 8, 3849, 304, 272, 408, 3849, 1021, 367, 9279, 3598, 1041, 421, 199, 533, 3101, 3849, 8, 3849, 304, 272, 408, 3849, 1021, 367, 3101, 3598, 1041, 421, 199, 318, 1104, 63, 875, 8, 1100, 12, 1559, 12, 13232, 29, 19, 304, 272, 340, 730, 8, 1113, 9, 365, 440, 620, 26, 267, 7987, 8, 16828, 3849, 3508, 83, 5074, 18792, 25182, 12, 4788, 450, 83, 7, 450, 288, 334, 1100, 12, 1559, 855, 533, 4914, 354, 29658, 421, 199, 533, 6924, 3296, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 304, 267, 291, 423, 1745, 275, 2547, 339, 347, 1586, 8, 277, 12, 627, 589, 304, 267, 340, 822, 8, 589, 9, 508, 378, 26, 288, 7987, 8, 16828, 3849, 360, 6508, 1630, 440, 24197, 376, 9027, 3608, 641, 314, 283, 2490, 283, 1210, 2547, 12, 12850, 10663, 4882, 370, 283, 2490, 283, 6508, 14, 1210, 14, 739, 342, 19293, 14, 221, 1448, 964, 316, 8037, 283, 2490, 283, 7551, 7078, 372, 687, 642, 1240, 8038, 326, 13232, 29, 18, 9, 267, 916, 822, 8, 589, 9, 1137, 413, 26, 288, 7987, 8, 16828, 3849, 360, 7354, 5002, 2633, 3032, 370, 12464, 14, 1210, 14, 739, 21898, 326, 13232, 29, 18, 9, 267, 372, 291, 423, 1745, 14, 739, 2031, 589, 9, 339, 347, 14441, 8, 277, 12, 627, 589, 304, 267, 340, 822, 8, 589, 9, 508, 378, 26, 288, 7987, 8, 16828, 3849, 360, 18287, 370, 12464, 14, 1210, 14, 6407, 342, 1928, 2368, 7, 2490, 283, 787, 19293, 14, 221, 3645, 12464, 14, 1210, 14, 739, 342, 3140, 8038, 326, 13232, 29, 18, 9, 267, 916, 822, 8, 589, 9, 508, 413, 26, 288, 7987, 8, 16828, 3849, 360, 6508, 14, 1210, 14, 6407, 342, 1990, 2797, 543, 282, 1568, 8328, 14, 283, 2490, 283, 16828, 1630, 440, 2291, 642, 12, 22160, 652, 3985, 83, 2808, 283, 2490, 283, 265, 1006, 12160, 8037, 8038, 326, 13232, 29, 18, 9, 267, 587, 26, 288, 746, 3146, 360, 7354, 5002, 2368, 3032, 370, 12464, 14, 1210, 14, 6407, 19004, 267, 372, 291, 423, 1745, 14, 6407, 2031, 589, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 862, 26, 288, 372, 2740, 8, 277, 423, 1745, 9, 267, 871, 3146, 26, 288, 7987, 8, 16828, 3849, 360, 6508, 14, 1210, 365, 440, 6076, 8038, 13232, 29, 18, 9, 288, 372, 2740, 30812, 339, 347, 4002, 8, 277, 304, 267, 7987, 8, 16828, 3849, 360, 3578, 6876, 314, 1324, 2547, 15659, 1467, 13232, 29, 18, 9, 267, 291, 423, 1745, 14, 1600, 342, 421, 199, 533, 4520, 3296, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2547, 304, 267, 291, 423, 1745, 275, 2547, 339, 347, 2218, 8, 277, 12, 308, 304, 267, 1104, 63, 875, 360, 6508, 14, 705, 14, 952, 19633, 308, 9, 267, 291, 423, 1745, 14, 952, 8, 83, 9, 339, 347, 8976, 8, 277, 304, 267, 291, 423, 1745, 14, 4939, 342, 339, 347, 2218, 1278, 8, 277, 12, 5412, 304, 267, 367, 1004, 315, 5412, 26, 288, 291, 14, 952, 8, 3610, 9, 339, 347, 4002, 8, 277, 304, 267, 7987, 8, 16828, 3849, 360, 3578, 6876, 314, 1125, 2547, 15659, 1467, 13232, 29, 18, 9, 267, 291, 423, 1745, 14, 1600, 342, 421, 199, 533, 12436, 12910, 3534, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 2218, 12, 8291, 304, 267, 291, 423, 952, 275, 2218, 267, 291, 423, 10660, 275, 8291, 339, 347, 636, 1250, 721, 277, 12, 308, 304, 267, 1104, 63, 875, 360, 952, 19633, 308, 9, 267, 291, 423, 952, 14, 952, 8, 83, 9, 267, 291, 423, 10660, 14, 740, 8, 552, 8, 83, 430, 421, 199, 533, 12436, 12910, 3585, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 6122, 12, 2323, 63, 409, 12, 8291, 304, 267, 291, 423, 5778, 275, 6122, 267, 291, 423, 2184, 275, 2740, 8, 5778, 680, 2184, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 2139, 63, 409, 275, 2323, 63, 409, 267, 291, 14, 10660, 275, 8291, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 339, 347, 2163, 8, 277, 304, 267, 340, 291, 14, 5938, 26, 288, 7987, 8, 16828, 3849, 360, 1661, 972, 1806, 6876, 1145, 63, 1661, 659, 326, 13232, 29, 18, 9, 267, 4336, 275, 291, 423, 2184, 342, 267, 340, 440, 291, 14, 2139, 63, 409, 26, 288, 7987, 8, 16828, 3849, 360, 5039, 2138, 2544, 652, 283, 2490, 283, 8924, 314, 1177, 659, 13232, 29, 18, 9, 267, 1104, 63, 875, 360, 3578, 6122, 2974, 297, 4336, 9, 267, 291, 14, 10660, 14, 740, 8, 552, 8, 6310, 430, 267, 372, 4336, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 5938, 275, 715, 267, 340, 2688, 8, 277, 423, 5778, 12, 283, 1600, 735, 288, 291, 423, 5778, 14, 1600, 342, 398, 340, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
IQSS/miniverse
miniverse/settings/local_with_routing.py
1
6078
""" Settings template for running two databases: - Existing Dataverse databases (we only read it) - Second database for Django core apps + Miniverse apps Please read through and change the settings where noted """ from __future__ import absolute_import import sys from os import makedirs, environ from os.path import join, isdir from miniverse.testrunners.disable_migrations import DisableMigrations from miniverse.settings.base import * # ----------------------------------- # DEBUG # - True: Dataverse Key required for API # - Includes SQL for many of the API call results # ----------------------------------- DEBUG = True #True False # ----------------------------------- # TIME_ZONE # ----------------------------------- TIME_ZONE = 'America/New_York' # ----------------------------------- # Secret key # ----------------------------------- SECRET_KEY = 'DEV-j94xnz*dj5f@_6-gt@ov)yjbcx0uagb7sv9a0j-(jo)j%m$el%' # ----------------------------------- # Metrics cache settings # ----------------------------------- METRICS_CACHE_VIEW = False METRICS_CACHE_VIEW_TIME = 60 * 60 * 2 # Cache for visualizations METRICS_CACHE_API_TIME = 60 * 15 # Cache for API endpoints # ----------------------------------- # For local runs, this directory will include: # - static files (after running 'collectstatic') # - optional, sqlite db if that's used for the Django apps db # ----------------------------------- LOCAL_SETUP_DIR = join(PROJECT_ROOT, 'test_setup') if not isdir(LOCAL_SETUP_DIR): makedirs(LOCAL_SETUP_DIR) # ----------------------------------- # Database routing. # e.g. between the Dataverse db and Django db # ----------------------------------- DATABASE_ROUTERS = ['miniverse.db_routers.db_dataverse_router.DataverseRouter',] # ----------------------------------- # URL of the Dataverse db being read # ----------------------------------- #DATAVERSE_INSTALLATION_URL = 'https://demo.dataverse.org' #DATAVERSE_INSTALLATION_URL = 'https://dataverse.harvard.edu' DATAVERSE_INSTALLATION_URL = 'http://localhost:8080' # ----------------------------------- # Database Setup # - default -> Create a new db for the django/miniverse specific apps # - May be any relational db type: postgres, sqlite, etc # - dataverse -> Read-only users for the Dataverse Posgres db # ----------------------------------- DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': join(LOCAL_SETUP_DIR, 'miniverse_default.db3'), }, 'dataverse': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'dvndb', # dvndb_demo, dvn_thedata, dvndb 'USER': 'postgres', # Set to a read-only user 'PASSWORD': '123', 'HOST': 'localhost', 'TEST': { 'MIRROR': 'default', # For running tests, only create 1 db }, } } # ----------------------------------- # Need when running DEBUG = False # ----------------------------------- ALLOWED_HOSTS = ('127.0.0.1', 'dd7be506.ngrok.io') # ----------------------------------- # Need to set when RestrictAdminMiddleware is active # ----------------------------------- INTERNAL_IPS = ('127.0.0.1',) # ----------------------------------- # Slackbot # ----------------------------------- SLACK_USERNAME = 'dvbot' SLACK_BOT_TOKEN = environ.get('SLACK_BOT_TOKEN') BOT_ID = environ.get('BOT_ID') SLACK_WEBHOOK_SECRET = environ.get('SLACK_WEBHOOK_SECRET') # ----------------------------------- # Optional MIDDLEWARE_CLASSES # ----------------------------------- MIDDLEWARE_CLASSES += [ # Restrict by IP address #'dv_apps.admin_restrict.middleware.RestrictAdminMiddleware', # Email about broken 404s #'django.middleware.common.BrokenLinkEmailsMiddleware', ] # ----------------------------------- # cookie name # ----------------------------------- SESSION_COOKIE_NAME = 'dv_metrics' # ----------------------------------- # Where static files are collected # ----------------------------------- STATIC_ROOT = join(LOCAL_SETUP_DIR, 'staticfiles') if not isdir(STATIC_ROOT): makedirs(STATIC_ROOT) # ----------------------------------- # Django Debug TOOLBAR CONFIGURATION # ----------------------------------- # See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup # ----------------------------------- INSTALLED_APPS += ( 'debug_toolbar', 'django.contrib.admindocs', ) MIDDLEWARE_CLASSES += [ 'debug_toolbar.middleware.DebugToolbarMiddleware', ] DEBUG_TOOLBAR_PATCH_SETTINGS = False # http://django-debug-toolbar.readthedocs.org/en/latest/installation.html # ----------------------------------- # For running tests: # - Only create 1 test database it has to be a Postgres db # - Remove the Database routing # - Disable migrations. e.g., We don't want to run them # - Set a new TEST_RUNNER: # - We want to *create* unmanaged tables in the test db # - Disable timezone awareness for fixture loading # ----------------------------------- if 'test' in sys.argv or 'test_coverage' in sys.argv: # Covers regular testing and django-coverage DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' DATABASES['default']['HOST'] = 'localhost' DATABASES['default']['USER'] = 'postgres' DATABASES['default']['PASSWORD'] = '123' # The custom routers we're using to route certain ORM queries # to the remote host conflict with our overridden db settings. # Set DATABASE_ROUTERS to an empty list to return to the defaults # during the test run. DATABASE_ROUTERS = [] MIGRATION_MODULES = DisableMigrations() # Set Django's test runner a custom class that will create # 'unmanaged' tables TEST_RUNNER = 'miniverse.testrunners.managed_model_test_runner.ManagedModelTestRunner' # Disable timezone awareness to False to avoid warnings when loading fixtures # e.g. to avoid: RuntimeWarning: (some object)received a naive datetime (2016-08-16 # 09:25:41.349000) while time zone support is active. USE_TZ = False
mit
[ 624, 199, 5268, 1978, 367, 3879, 2877, 16219, 26, 272, 446, 1316, 26958, 3918, 2077, 16219, 334, 1129, 1454, 1586, 652, 9, 272, 446, 16707, 3050, 367, 5634, 6170, 8686, 435, 24954, 2077, 8686, 199, 199, 8254, 1586, 4012, 436, 1570, 314, 2202, 2382, 949, 471, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 984, 199, 504, 747, 492, 1852, 3220, 12, 6160, 199, 504, 747, 14, 515, 492, 4263, 12, 26004, 199, 504, 20536, 2077, 14, 396, 32213, 14, 5993, 63, 7685, 492, 17534, 19322, 3801, 199, 504, 20536, 2077, 14, 1751, 14, 1095, 492, 627, 199, 199, 3, 11016, 2595, 199, 3, 10990, 199, 3, 257, 446, 715, 26, 3918, 2077, 2606, 1415, 367, 3261, 199, 3, 755, 446, 15783, 83, 5385, 367, 5002, 402, 314, 3261, 1240, 2058, 199, 3, 11016, 2595, 199, 5287, 275, 715, 257, 327, 549, 756, 199, 199, 3, 11016, 2595, 199, 3, 17032, 63, 15353, 199, 3, 11016, 2595, 199, 4961, 63, 15353, 275, 283, 8841, 15, 4665, 63, 57, 4708, 7, 199, 199, 3, 11016, 2595, 199, 3, 23580, 790, 199, 3, 11016, 2595, 199, 12961, 63, 3078, 275, 283, 13260, 13, 74, 2635, 5032, 90, 10, 18256, 21, 70, 17608, 22, 13, 3308, 32, 8822, 9, 89, 74, 3776, 88, 16, 85, 643, 66, 23, 2772, 25, 65, 16, 74, 15426, 743, 9, 74, 5, 77, 4, 352, 5, 7, 199, 199, 3, 11016, 2595, 199, 3, 10072, 11818, 2581, 2202, 199, 3, 11016, 2595, 199, 30476, 63, 8677, 63, 12058, 275, 756, 199, 30476, 63, 8677, 63, 12058, 63, 4961, 275, 5212, 627, 5212, 627, 499, 257, 327, 11977, 367, 13104, 12270, 199, 30476, 63, 8677, 63, 3735, 63, 4961, 275, 5212, 627, 4114, 259, 327, 11977, 367, 3261, 16173, 199, 199, 3, 11016, 2595, 199, 3, 2104, 2257, 7858, 12, 642, 2082, 911, 2387, 26, 199, 3, 257, 446, 2955, 1584, 334, 4399, 3879, 283, 7112, 1986, 358, 199, 3, 257, 446, 2716, 12, 11723, 1592, 340, 626, 1159, 1202, 367, 314, 5634, 8686, 1592, 199, 3, 11016, 2595, 199, 7486, 63, 20836, 63, 3022, 275, 4263, 8, 10797, 63, 5441, 12, 283, 396, 63, 2758, 358, 199, 692, 440, 26004, 8, 7486, 63, 20836, 63, 3022, 304, 272, 1852, 3220, 8, 7486, 63, 20836, 63, 3022, 9, 199, 199, 3, 11016, 2595, 199, 3, 8692, 14870, 14, 199, 3, 257, 325, 14, 71, 14, 3382, 314, 3918, 2077, 1592, 436, 5634, 1592, 199, 3, 11016, 2595, 199, 17873, 63, 14999, 3960, 275, 788, 18000, 2077, 14, 697, 63, 17292, 14, 697, 63, 576, 2077, 63, 4995, 14, 1451, 2077, 11691, 297, 61, 199, 199, 3, 11016, 2595, 199, 3, 2851, 402, 314, 3918, 2077, 1592, 3769, 1586, 199, 3, 11016, 2595, 199, 3, 3998, 21233, 63, 16811, 2594, 63, 2632, 275, 283, 2859, 921, 8768, 14, 576, 2077, 14, 1308, 7, 199, 3, 3998, 21233, 63, 16811, 2594, 63, 2632, 275, 283, 2859, 921, 576, 2077, 14, 8210, 86, 1005, 14, 8654, 7, 199, 3998, 21233, 63, 16811, 2594, 63, 2632, 275, 283, 1014, 921, 5967, 26, 15844, 7, 199, 199, 3, 11016, 2595, 199, 3, 8692, 12439, 199, 3, 257, 446, 849, 1035, 2790, 282, 892, 1592, 367, 314, 1639, 15, 18000, 2077, 2488, 8686, 199, 3, 755, 446, 10162, 506, 1263, 5850, 279, 1592, 730, 26, 19533, 12, 11723, 12, 5423, 199, 3, 257, 446, 666, 2077, 1035, 5574, 13, 2118, 4390, 367, 314, 3918, 2077, 25987, 7266, 1592, 199, 3, 11016, 2595, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 4263, 8, 7486, 63, 20836, 63, 3022, 12, 283, 18000, 2077, 63, 885, 14, 697, 19, 659, 272, 1660, 272, 283, 576, 2077, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 15437, 63, 20270, 18, 297, 267, 283, 2339, 356, 283, 68, 6002, 697, 297, 221, 327, 366, 6002, 697, 63, 8768, 12, 366, 6002, 63, 20741, 419, 12, 366, 6002, 697, 267, 283, 3791, 356, 283, 10675, 297, 258, 327, 2494, 370, 282, 1586, 13, 2118, 922, 267, 283, 9032, 356, 283, 4288, 297, 267, 283, 5449, 356, 283, 5967, 297, 267, 283, 2864, 356, 469, 288, 283, 45, 3927, 50, 726, 356, 283, 885, 297, 327, 2104, 3879, 2295, 12, 1454, 1218, 413, 1592, 267, 1660, 272, 789, 199, 93, 421, 199, 3, 11016, 2595, 199, 3, 14012, 1380, 3879, 10990, 275, 756, 199, 3, 11016, 2595, 199, 17350, 63, 23775, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 617, 23, 1235, 13725, 14, 2753, 29275, 14, 2308, 358, 199, 199, 3, 11016, 2595, 199, 3, 14012, 370, 663, 1380, 799, 4768, 4880, 6608, 365, 4702, 199, 3, 11016, 2595, 199, 17681, 63, 12346, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 9538, 421, 199, 3, 11016, 2595, 199, 3, 428, 5143, 3018, 199, 3, 11016, 2595, 199, 4929, 3099, 63, 11958, 275, 283, 8398, 3018, 7, 199, 4929, 3099, 63, 11372, 63, 8803, 275, 6160, 14, 362, 360, 4929, 3099, 63, 11372, 63, 8803, 358, 199, 11372, 63, 998, 275, 221, 6160, 14, 362, 360, 11372, 63, 998, 358, 199, 4929, 3099, 63, 13166, 28706, 63, 12961, 275, 6160, 14, 362, 360, 4929, 3099, 63, 13166, 28706, 63, 12961, 358, 199, 199, 3, 11016, 2595, 199, 3, 4879, 30718, 63, 13748, 199, 3, 11016, 2595, 199, 19987, 63, 13748, 847, 359, 272, 327, 799, 4768, 701, 3531, 2287, 272, 17384, 8398, 63, 5181, 14, 2113, 63, 22188, 14, 5754, 14, 497, 4768, 4880, 6608, 297, 272, 327, 11426, 3595, 10529, 7901, 83, 272, 17384, 1176, 14, 5754, 14, 2330, 14, 30509, 3834, 7035, 83, 6608, 297, 199, 61, 199, 199, 3, 11016, 2595, 199, 3, 5494, 536, 199, 3, 11016, 2595, 199, 12763, 63, 13665, 63, 2339, 275, 283, 8398, 63, 6759, 7, 199, 199, 3, 11016, 2595, 199, 3, 17685, 2955, 1584, 787, 13736, 199, 3, 11016, 2595, 199, 10449, 63, 5441, 275, 4263, 8, 7486, 63, 20836, 63, 3022, 12, 283, 18373, 358, 199, 692, 440, 26004, 8, 10449, 63 ]
[ 199, 5268, 1978, 367, 3879, 2877, 16219, 26, 272, 446, 1316, 26958, 3918, 2077, 16219, 334, 1129, 1454, 1586, 652, 9, 272, 446, 16707, 3050, 367, 5634, 6170, 8686, 435, 24954, 2077, 8686, 199, 199, 8254, 1586, 4012, 436, 1570, 314, 2202, 2382, 949, 471, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 984, 199, 504, 747, 492, 1852, 3220, 12, 6160, 199, 504, 747, 14, 515, 492, 4263, 12, 26004, 199, 504, 20536, 2077, 14, 396, 32213, 14, 5993, 63, 7685, 492, 17534, 19322, 3801, 199, 504, 20536, 2077, 14, 1751, 14, 1095, 492, 627, 199, 199, 3, 11016, 2595, 199, 3, 10990, 199, 3, 257, 446, 715, 26, 3918, 2077, 2606, 1415, 367, 3261, 199, 3, 755, 446, 15783, 83, 5385, 367, 5002, 402, 314, 3261, 1240, 2058, 199, 3, 11016, 2595, 199, 5287, 275, 715, 257, 327, 549, 756, 199, 199, 3, 11016, 2595, 199, 3, 17032, 63, 15353, 199, 3, 11016, 2595, 199, 4961, 63, 15353, 275, 283, 8841, 15, 4665, 63, 57, 4708, 7, 199, 199, 3, 11016, 2595, 199, 3, 23580, 790, 199, 3, 11016, 2595, 199, 12961, 63, 3078, 275, 283, 13260, 13, 74, 2635, 5032, 90, 10, 18256, 21, 70, 17608, 22, 13, 3308, 32, 8822, 9, 89, 74, 3776, 88, 16, 85, 643, 66, 23, 2772, 25, 65, 16, 74, 15426, 743, 9, 74, 5, 77, 4, 352, 5, 7, 199, 199, 3, 11016, 2595, 199, 3, 10072, 11818, 2581, 2202, 199, 3, 11016, 2595, 199, 30476, 63, 8677, 63, 12058, 275, 756, 199, 30476, 63, 8677, 63, 12058, 63, 4961, 275, 5212, 627, 5212, 627, 499, 257, 327, 11977, 367, 13104, 12270, 199, 30476, 63, 8677, 63, 3735, 63, 4961, 275, 5212, 627, 4114, 259, 327, 11977, 367, 3261, 16173, 199, 199, 3, 11016, 2595, 199, 3, 2104, 2257, 7858, 12, 642, 2082, 911, 2387, 26, 199, 3, 257, 446, 2955, 1584, 334, 4399, 3879, 283, 7112, 1986, 358, 199, 3, 257, 446, 2716, 12, 11723, 1592, 340, 626, 1159, 1202, 367, 314, 5634, 8686, 1592, 199, 3, 11016, 2595, 199, 7486, 63, 20836, 63, 3022, 275, 4263, 8, 10797, 63, 5441, 12, 283, 396, 63, 2758, 358, 199, 692, 440, 26004, 8, 7486, 63, 20836, 63, 3022, 304, 272, 1852, 3220, 8, 7486, 63, 20836, 63, 3022, 9, 199, 199, 3, 11016, 2595, 199, 3, 8692, 14870, 14, 199, 3, 257, 325, 14, 71, 14, 3382, 314, 3918, 2077, 1592, 436, 5634, 1592, 199, 3, 11016, 2595, 199, 17873, 63, 14999, 3960, 275, 788, 18000, 2077, 14, 697, 63, 17292, 14, 697, 63, 576, 2077, 63, 4995, 14, 1451, 2077, 11691, 297, 61, 199, 199, 3, 11016, 2595, 199, 3, 2851, 402, 314, 3918, 2077, 1592, 3769, 1586, 199, 3, 11016, 2595, 199, 3, 3998, 21233, 63, 16811, 2594, 63, 2632, 275, 283, 2859, 921, 8768, 14, 576, 2077, 14, 1308, 7, 199, 3, 3998, 21233, 63, 16811, 2594, 63, 2632, 275, 283, 2859, 921, 576, 2077, 14, 8210, 86, 1005, 14, 8654, 7, 199, 3998, 21233, 63, 16811, 2594, 63, 2632, 275, 283, 1014, 921, 5967, 26, 15844, 7, 199, 199, 3, 11016, 2595, 199, 3, 8692, 12439, 199, 3, 257, 446, 849, 1035, 2790, 282, 892, 1592, 367, 314, 1639, 15, 18000, 2077, 2488, 8686, 199, 3, 755, 446, 10162, 506, 1263, 5850, 279, 1592, 730, 26, 19533, 12, 11723, 12, 5423, 199, 3, 257, 446, 666, 2077, 1035, 5574, 13, 2118, 4390, 367, 314, 3918, 2077, 25987, 7266, 1592, 199, 3, 11016, 2595, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 267, 283, 2339, 356, 4263, 8, 7486, 63, 20836, 63, 3022, 12, 283, 18000, 2077, 63, 885, 14, 697, 19, 659, 272, 1660, 272, 283, 576, 2077, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 15437, 63, 20270, 18, 297, 267, 283, 2339, 356, 283, 68, 6002, 697, 297, 221, 327, 366, 6002, 697, 63, 8768, 12, 366, 6002, 63, 20741, 419, 12, 366, 6002, 697, 267, 283, 3791, 356, 283, 10675, 297, 258, 327, 2494, 370, 282, 1586, 13, 2118, 922, 267, 283, 9032, 356, 283, 4288, 297, 267, 283, 5449, 356, 283, 5967, 297, 267, 283, 2864, 356, 469, 288, 283, 45, 3927, 50, 726, 356, 283, 885, 297, 327, 2104, 3879, 2295, 12, 1454, 1218, 413, 1592, 267, 1660, 272, 789, 199, 93, 421, 199, 3, 11016, 2595, 199, 3, 14012, 1380, 3879, 10990, 275, 756, 199, 3, 11016, 2595, 199, 17350, 63, 23775, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 617, 23, 1235, 13725, 14, 2753, 29275, 14, 2308, 358, 199, 199, 3, 11016, 2595, 199, 3, 14012, 370, 663, 1380, 799, 4768, 4880, 6608, 365, 4702, 199, 3, 11016, 2595, 199, 17681, 63, 12346, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 9538, 421, 199, 3, 11016, 2595, 199, 3, 428, 5143, 3018, 199, 3, 11016, 2595, 199, 4929, 3099, 63, 11958, 275, 283, 8398, 3018, 7, 199, 4929, 3099, 63, 11372, 63, 8803, 275, 6160, 14, 362, 360, 4929, 3099, 63, 11372, 63, 8803, 358, 199, 11372, 63, 998, 275, 221, 6160, 14, 362, 360, 11372, 63, 998, 358, 199, 4929, 3099, 63, 13166, 28706, 63, 12961, 275, 6160, 14, 362, 360, 4929, 3099, 63, 13166, 28706, 63, 12961, 358, 199, 199, 3, 11016, 2595, 199, 3, 4879, 30718, 63, 13748, 199, 3, 11016, 2595, 199, 19987, 63, 13748, 847, 359, 272, 327, 799, 4768, 701, 3531, 2287, 272, 17384, 8398, 63, 5181, 14, 2113, 63, 22188, 14, 5754, 14, 497, 4768, 4880, 6608, 297, 272, 327, 11426, 3595, 10529, 7901, 83, 272, 17384, 1176, 14, 5754, 14, 2330, 14, 30509, 3834, 7035, 83, 6608, 297, 199, 61, 199, 199, 3, 11016, 2595, 199, 3, 5494, 536, 199, 3, 11016, 2595, 199, 12763, 63, 13665, 63, 2339, 275, 283, 8398, 63, 6759, 7, 199, 199, 3, 11016, 2595, 199, 3, 17685, 2955, 1584, 787, 13736, 199, 3, 11016, 2595, 199, 10449, 63, 5441, 275, 4263, 8, 7486, 63, 20836, 63, 3022, 12, 283, 18373, 358, 199, 692, 440, 26004, 8, 10449, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
caiminf/freenos
site_scons/ext2.py
11
1950
# # Copyright (C) 2009 Niek Linnenbank # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import os import tempfile import shutil from build import * from SCons.Script import * from SCons.Action import * # # Generate an Extended 2 Filesystem image. # def generateExt2(target, source, env): # Open the list. list = open(str(source[0])) # Copy the entire project. shutil.copytree(".", "tmproot") # Strip all binaries. os.system("strip `find tmproot` 2> /dev/null") # Create an Extended 2 Filesystem image. os.system("srv/filesystem/ext2/host/create " + str(target[0]) + " tmproot -e '*.cpp' -e '*.h' -e '*.c' -e '*.o' -e 'lib*' -e 'doc' " " -e 'SCons*' -e '*.a' -e '*.S' -e '*.ld' -e 'boot*'") # Done. os.system("rm -rf tmproot") list.close() # # Prints out a user friendly command-line string. # def generateExt2Str(target, source, env): return " EXT2 " + str(target[0]) # # Create extended 2 builder. # ext2Builder = Builder(action = Action(generateExt2, generateExt2Str), suffix = '.ext2', src_suffix = '.ext2desc') target.Append(BUILDERS = { 'Ext2' : ext2Builder }) # # Specify dependencies and targets. # ext2 = target.Ext2('boot/boot.ext2', ['boot/boot.ext2desc']) Depends(ext2, ['bin', 'lib', 'kernel', 'sbin', 'srv']) AlwaysBuild(ext2)
gpl-3.0
[ 3, 199, 3, 1898, 334, 35, 9, 8937, 653, 1873, 75, 29730, 78, 287, 9860, 199, 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 747, 199, 646, 5549, 199, 646, 5145, 199, 199, 504, 1900, 492, 627, 199, 504, 8218, 14, 5229, 492, 627, 199, 504, 8218, 14, 3310, 492, 627, 199, 199, 3, 199, 3, 7958, 376, 13706, 499, 3814, 2253, 1834, 14, 199, 3, 199, 318, 3550, 4942, 18, 8, 1375, 12, 1350, 12, 2589, 304, 339, 327, 3232, 314, 769, 14, 272, 769, 275, 1551, 8, 495, 8, 1365, 59, 16, 2459, 2286, 327, 11247, 314, 8039, 2199, 14, 272, 5145, 14, 29296, 30381, 298, 2791, 1231, 531, 339, 327, 19828, 1006, 21984, 14, 272, 747, 14, 2253, 480, 1913, 658, 1623, 3529, 1231, 64, 499, 30, 1182, 2374, 15, 2307, 531, 2286, 327, 2790, 376, 13706, 499, 3814, 2253, 1834, 14, 272, 747, 14, 2253, 480, 15165, 15, 11381, 15, 832, 18, 15, 1102, 15, 981, 298, 435, 620, 8, 1375, 59, 16, 566, 435, 507, 420, 298, 3529, 1231, 446, 69, 11937, 5910, 7, 446, 69, 11937, 72, 7, 446, 69, 11937, 67, 7, 446, 69, 11937, 79, 7, 446, 69, 283, 773, 10223, 446, 69, 283, 1301, 7, 298, 507, 420, 298, 446, 69, 283, 18521, 10223, 446, 69, 11937, 65, 7, 446, 69, 11937, 51, 7, 446, 69, 11937, 1447, 7, 446, 69, 283, 4930, 10, 9859, 339, 327, 23541, 14, 272, 747, 14, 2253, 480, 5682, 446, 3941, 3529, 1231, 531, 272, 769, 14, 1600, 342, 199, 199, 3, 199, 3, 9101, 83, 734, 282, 922, 21428, 1414, 13, 604, 1059, 14, 199, 3, 199, 318, 3550, 4942, 18, 2848, 8, 1375, 12, 1350, 12, 2589, 304, 339, 372, 298, 221, 20203, 18, 259, 298, 435, 620, 8, 1375, 59, 16, 566, 199, 199, 3, 199, 3, 2790, 9243, 499, 6545, 14, 199, 3, 199, 832, 18, 6437, 275, 19286, 8, 1287, 258, 275, 10033, 8, 4208, 4942, 18, 12, 3550, 4942, 18, 2848, 395, 507, 258, 198, 420, 4739, 258, 275, 1987, 832, 18, 297, 507, 258, 198, 420, 2928, 63, 4511, 275, 1987, 832, 18, 3257, 358, 199, 199, 1375, 14, 8310, 8, 8248, 3960, 275, 469, 283, 4942, 18, 7, 520, 1599, 18, 6437, 3828, 199, 199, 3, 199, 3, 13327, 5124, 436, 4545, 14, 199, 3, 199, 832, 18, 275, 1347, 14, 4942, 18, 360, 4930, 15, 4930, 14, 832, 18, 297, 788, 4930, 15, 4930, 14, 832, 18, 3257, 1105, 199, 8598, 3198, 8, 832, 18, 12, 788, 1393, 297, 283, 773, 297, 283, 4989, 297, 283, 21457, 297, 283, 15165, 1105, 199, 2439, 2885, 3425, 8, 832, 18, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 35, 9, 8937, 653, 1873, 75, 29730, 78, 287, 9860, 199, 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 646, 747, 199, 646, 5549, 199, 646, 5145, 199, 199, 504, 1900, 492, 627, 199, 504, 8218, 14, 5229, 492, 627, 199, 504, 8218, 14, 3310, 492, 627, 199, 199, 3, 199, 3, 7958, 376, 13706, 499, 3814, 2253, 1834, 14, 199, 3, 199, 318, 3550, 4942, 18, 8, 1375, 12, 1350, 12, 2589, 304, 339, 327, 3232, 314, 769, 14, 272, 769, 275, 1551, 8, 495, 8, 1365, 59, 16, 2459, 2286, 327, 11247, 314, 8039, 2199, 14, 272, 5145, 14, 29296, 30381, 298, 2791, 1231, 531, 339, 327, 19828, 1006, 21984, 14, 272, 747, 14, 2253, 480, 1913, 658, 1623, 3529, 1231, 64, 499, 30, 1182, 2374, 15, 2307, 531, 2286, 327, 2790, 376, 13706, 499, 3814, 2253, 1834, 14, 272, 747, 14, 2253, 480, 15165, 15, 11381, 15, 832, 18, 15, 1102, 15, 981, 298, 435, 620, 8, 1375, 59, 16, 566, 435, 507, 420, 298, 3529, 1231, 446, 69, 11937, 5910, 7, 446, 69, 11937, 72, 7, 446, 69, 11937, 67, 7, 446, 69, 11937, 79, 7, 446, 69, 283, 773, 10223, 446, 69, 283, 1301, 7, 298, 507, 420, 298, 446, 69, 283, 18521, 10223, 446, 69, 11937, 65, 7, 446, 69, 11937, 51, 7, 446, 69, 11937, 1447, 7, 446, 69, 283, 4930, 10, 9859, 339, 327, 23541, 14, 272, 747, 14, 2253, 480, 5682, 446, 3941, 3529, 1231, 531, 272, 769, 14, 1600, 342, 199, 199, 3, 199, 3, 9101, 83, 734, 282, 922, 21428, 1414, 13, 604, 1059, 14, 199, 3, 199, 318, 3550, 4942, 18, 2848, 8, 1375, 12, 1350, 12, 2589, 304, 339, 372, 298, 221, 20203, 18, 259, 298, 435, 620, 8, 1375, 59, 16, 566, 199, 199, 3, 199, 3, 2790, 9243, 499, 6545, 14, 199, 3, 199, 832, 18, 6437, 275, 19286, 8, 1287, 258, 275, 10033, 8, 4208, 4942, 18, 12, 3550, 4942, 18, 2848, 395, 507, 258, 198, 420, 4739, 258, 275, 1987, 832, 18, 297, 507, 258, 198, 420, 2928, 63, 4511, 275, 1987, 832, 18, 3257, 358, 199, 199, 1375, 14, 8310, 8, 8248, 3960, 275, 469, 283, 4942, 18, 7, 520, 1599, 18, 6437, 3828, 199, 199, 3, 199, 3, 13327, 5124, 436, 4545, 14, 199, 3, 199, 832, 18, 275, 1347, 14, 4942, 18, 360, 4930, 15, 4930, 14, 832, 18, 297, 788, 4930, 15, 4930, 14, 832, 18, 3257, 1105, 199, 8598, 3198, 8, 832, 18, 12, 788, 1393, 297, 283, 773, 297, 283, 4989, 297, 283, 21457, 297, 283, 15165, 1105, 199, 2439, 2885, 3425, 8, 832, 18, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
trungnt13/scikit-learn
sklearn/feature_selection/__init__.py
244
1088
""" The :mod:`sklearn.feature_selection` module implements feature selection algorithms. It currently includes univariate filter selection methods and the recursive feature elimination algorithm. """ from .univariate_selection import chi2 from .univariate_selection import f_classif from .univariate_selection import f_oneway from .univariate_selection import f_regression from .univariate_selection import SelectPercentile from .univariate_selection import SelectKBest from .univariate_selection import SelectFpr from .univariate_selection import SelectFdr from .univariate_selection import SelectFwe from .univariate_selection import GenericUnivariateSelect from .variance_threshold import VarianceThreshold from .rfe import RFE from .rfe import RFECV __all__ = ['GenericUnivariateSelect', 'RFE', 'RFECV', 'SelectFdr', 'SelectFpr', 'SelectFwe', 'SelectKBest', 'SelectPercentile', 'VarianceThreshold', 'chi2', 'f_classif', 'f_oneway', 'f_regression']
bsd-3-clause
[ 624, 199, 1918, 520, 1494, 1705, 27993, 14, 4445, 63, 5592, 64, 859, 9031, 3878, 7267, 199, 24365, 14, 2779, 5544, 6952, 17225, 18449, 2457, 7267, 3102, 436, 314, 199, 9931, 3878, 20714, 425, 5563, 14, 199, 624, 199, 199, 504, 1275, 324, 23225, 63, 5592, 492, 23275, 18, 199, 504, 1275, 324, 23225, 63, 5592, 492, 289, 63, 12334, 70, 199, 504, 1275, 324, 23225, 63, 5592, 492, 289, 63, 368, 3316, 199, 504, 1275, 324, 23225, 63, 5592, 492, 289, 63, 12513, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 2623, 15691, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 12780, 597, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 38, 2700, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 38, 5012, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 38, 1129, 199, 504, 1275, 324, 23225, 63, 5592, 492, 8307, 1358, 23225, 5446, 199, 199, 504, 1275, 6221, 63, 7227, 492, 21107, 554, 12109, 199, 199, 504, 1275, 82, 771, 492, 820, 5100, 199, 504, 1275, 82, 771, 492, 820, 38, 4220, 54, 199, 199, 363, 452, 363, 275, 788, 9417, 1358, 23225, 5446, 297, 1779, 283, 50, 5100, 297, 1779, 283, 11778, 4220, 54, 297, 1779, 283, 5446, 38, 5012, 297, 1779, 283, 5446, 38, 2700, 297, 1779, 283, 5446, 38, 1129, 297, 1779, 283, 5446, 12780, 597, 297, 1779, 283, 5446, 2623, 15691, 297, 1779, 283, 31805, 12109, 297, 1779, 283, 13175, 18, 297, 1779, 283, 70, 63, 12334, 70, 297, 1779, 283, 70, 63, 368, 3316, 297, 1779, 283, 70, 63, 12513, 418, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 1918, 520, 1494, 1705, 27993, 14, 4445, 63, 5592, 64, 859, 9031, 3878, 7267, 199, 24365, 14, 2779, 5544, 6952, 17225, 18449, 2457, 7267, 3102, 436, 314, 199, 9931, 3878, 20714, 425, 5563, 14, 199, 624, 199, 199, 504, 1275, 324, 23225, 63, 5592, 492, 23275, 18, 199, 504, 1275, 324, 23225, 63, 5592, 492, 289, 63, 12334, 70, 199, 504, 1275, 324, 23225, 63, 5592, 492, 289, 63, 368, 3316, 199, 504, 1275, 324, 23225, 63, 5592, 492, 289, 63, 12513, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 2623, 15691, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 12780, 597, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 38, 2700, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 38, 5012, 199, 504, 1275, 324, 23225, 63, 5592, 492, 9496, 38, 1129, 199, 504, 1275, 324, 23225, 63, 5592, 492, 8307, 1358, 23225, 5446, 199, 199, 504, 1275, 6221, 63, 7227, 492, 21107, 554, 12109, 199, 199, 504, 1275, 82, 771, 492, 820, 5100, 199, 504, 1275, 82, 771, 492, 820, 38, 4220, 54, 199, 199, 363, 452, 363, 275, 788, 9417, 1358, 23225, 5446, 297, 1779, 283, 50, 5100, 297, 1779, 283, 11778, 4220, 54, 297, 1779, 283, 5446, 38, 5012, 297, 1779, 283, 5446, 38, 2700, 297, 1779, 283, 5446, 38, 1129, 297, 1779, 283, 5446, 12780, 597, 297, 1779, 283, 5446, 2623, 15691, 297, 1779, 283, 31805, 12109, 297, 1779, 283, 13175, 18, 297, 1779, 283, 70, 63, 12334, 70, 297, 1779, 283, 70, 63, 368, 3316, 297, 1779, 283, 70, 63, 12513, 418, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
RadioFreeAsia/RDacity
lib-src/lv2/lv2/plugins/eg-midigate.lv2/waflib/Tools/compiler_cxx.py
343
1762
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file import os,sys,imp,types from waflib.Tools import ccroot from waflib import Utils,Configure from waflib.Logs import debug cxx_compiler={'win32':['msvc','g++'],'cygwin':['g++'],'darwin':['g++'],'aix':['xlc++','g++'],'linux':['g++','icpc'],'sunos':['sunc++','g++'],'irix':['g++'],'hpux':['g++'],'gnu':['g++'],'java':['g++','msvc','icpc'],'default':['g++']} def configure(conf): try:test_for_compiler=conf.options.check_cxx_compiler except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_cxx')") for compiler in test_for_compiler.split(): conf.env.stash() conf.start_msg('Checking for %r (c++ compiler)'%compiler) try: conf.load(compiler) except conf.errors.ConfigurationError ,e: conf.env.revert() conf.end_msg(False) debug('compiler_cxx: %r'%e) else: if conf.env['CXX']: conf.end_msg(conf.env.get_flat('CXX')) conf.env['COMPILER_CXX']=compiler break conf.end_msg(False) else: conf.fatal('could not configure a c++ compiler!') def options(opt): opt.load_special_tools('cxx_*.py') global cxx_compiler build_platform=Utils.unversioned_sys_platform() possible_compiler_list=cxx_compiler[build_platform in cxx_compiler and build_platform or'default'] test_for_compiler=' '.join(possible_compiler_list) cxx_compiler_opts=opt.add_option_group('C++ Compiler Options') cxx_compiler_opts.add_option('--check-cxx-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following C++ Compiler will be checked by default: "%s"'%(build_platform,test_for_compiler),dest="check_cxx_compiler") for x in test_for_compiler.split(): opt.load('%s'%x)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 1274, 12, 3236, 12, 1313, 199, 504, 31380, 14, 11654, 492, 7429, 1231, 199, 504, 31380, 492, 17397, 12, 17324, 199, 504, 31380, 14, 16333, 492, 3105, 199, 9634, 63, 5772, 3713, 2676, 708, 21662, 19875, 1673, 71, 4176, 995, 7, 16680, 21662, 71, 4176, 995, 7, 13245, 21662, 71, 4176, 995, 7, 65, 1148, 21662, 88, 10181, 4176, 1673, 71, 4176, 995, 7, 5135, 21662, 71, 4176, 1673, 530, 2352, 995, 7, 11846, 736, 21662, 83, 1097, 4176, 1673, 71, 4176, 995, 7, 73, 1904, 21662, 71, 4176, 995, 7, 12025, 2521, 21662, 71, 4176, 995, 7, 3689, 21662, 71, 4176, 995, 7, 6138, 21662, 71, 4176, 1673, 19875, 1673, 530, 2352, 995, 7, 885, 21662, 71, 4176, 12074, 199, 318, 7908, 8, 2190, 304, 199, 198, 893, 26, 396, 63, 509, 63, 5772, 29, 2190, 14, 1419, 14, 1074, 63, 9634, 63, 5772, 199, 198, 2590, 4281, 26, 2190, 14, 16208, 480, 1123, 1511, 8, 2992, 304, 2450, 14, 912, 360, 5772, 63, 9634, 26530, 199, 198, 509, 6365, 315, 511, 63, 509, 63, 5772, 14, 1294, 837, 507, 198, 2190, 14, 1813, 14, 27145, 342, 507, 198, 2190, 14, 928, 63, 1328, 360, 14740, 367, 450, 82, 334, 67, 4176, 6365, 3171, 5, 5772, 9, 507, 198, 893, 26, 686, 198, 2190, 14, 912, 8, 5772, 9, 507, 198, 2590, 3743, 14, 2550, 14, 5688, 547, 2360, 69, 26, 686, 198, 2190, 14, 1813, 14, 19092, 342, 686, 198, 2190, 14, 500, 63, 1328, 8, 797, 9, 686, 198, 1757, 360, 5772, 63, 9634, 26, 450, 82, 5956, 69, 9, 507, 198, 2836, 26, 686, 198, 692, 3743, 14, 1813, 459, 12206, 2565, 1585, 198, 2190, 14, 500, 63, 1328, 8, 2190, 14, 1813, 14, 362, 63, 7088, 360, 12206, 1333, 1585, 198, 2190, 14, 1813, 459, 6790, 1193, 540, 63, 12206, 13784, 5772, 1585, 198, 4785, 686, 198, 2190, 14, 500, 63, 1328, 8, 797, 9, 199, 198, 2836, 26, 507, 198, 2190, 14, 16208, 360, 15153, 440, 7908, 282, 286, 4176, 6365, 10916, 199, 318, 1511, 8, 2992, 304, 199, 198, 2992, 14, 912, 63, 6664, 63, 2537, 360, 9634, 63, 4856, 647, 358, 199, 198, 2966, 17327, 63, 5772, 199, 198, 1506, 63, 3246, 29, 7535, 14, 324, 24155, 63, 1274, 63, 3246, 342, 199, 198, 13893, 63, 5772, 63, 513, 29, 9634, 63, 5772, 59, 1506, 63, 3246, 315, 17327, 63, 5772, 436, 1900, 63, 3246, 503, 5121, 69, 1879, 418, 199, 198, 396, 63, 509, 63, 5772, 534, 1987, 904, 8, 13893, 63, 5772, 63, 513, 9, 199, 198, 9634, 63, 5772, 63, 3291, 29, 2992, 14, 525, 63, 1422, 63, 923, 360, 35, 4176, 27154, 8394, 358, 199, 198, 9634, 63, 5772, 63, 3291, 14, 525, 63, 1422, 4517, 1074, 13, 9634, 13, 5772, 297, 885, 5961, 83, 6808, 396, 63, 509, 63, 5772, 12, 3437, 534, 3314, 642, 4298, 4366, 83, 9, 314, 2569, 445, 4176, 27154, 911, 506, 7923, 701, 849, 26, 2071, 83, 4507, 2840, 1506, 63, 3246, 12, 396, 63, 509, 63, 5772, 395, 2614, 628, 1074, 63, 9634, 63, 5772, 531, 199, 198, 509, 671, 315, 511, 63, 509, 63, 5772, 14, 1294, 837, 507, 198, 2992, 14, 912, 3508, 83, 5956, 88, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 1274, 12, 3236, 12, 1313, 199, 504, 31380, 14, 11654, 492, 7429, 1231, 199, 504, 31380, 492, 17397, 12, 17324, 199, 504, 31380, 14, 16333, 492, 3105, 199, 9634, 63, 5772, 3713, 2676, 708, 21662, 19875, 1673, 71, 4176, 995, 7, 16680, 21662, 71, 4176, 995, 7, 13245, 21662, 71, 4176, 995, 7, 65, 1148, 21662, 88, 10181, 4176, 1673, 71, 4176, 995, 7, 5135, 21662, 71, 4176, 1673, 530, 2352, 995, 7, 11846, 736, 21662, 83, 1097, 4176, 1673, 71, 4176, 995, 7, 73, 1904, 21662, 71, 4176, 995, 7, 12025, 2521, 21662, 71, 4176, 995, 7, 3689, 21662, 71, 4176, 995, 7, 6138, 21662, 71, 4176, 1673, 19875, 1673, 530, 2352, 995, 7, 885, 21662, 71, 4176, 12074, 199, 318, 7908, 8, 2190, 304, 199, 198, 893, 26, 396, 63, 509, 63, 5772, 29, 2190, 14, 1419, 14, 1074, 63, 9634, 63, 5772, 199, 198, 2590, 4281, 26, 2190, 14, 16208, 480, 1123, 1511, 8, 2992, 304, 2450, 14, 912, 360, 5772, 63, 9634, 26530, 199, 198, 509, 6365, 315, 511, 63, 509, 63, 5772, 14, 1294, 837, 507, 198, 2190, 14, 1813, 14, 27145, 342, 507, 198, 2190, 14, 928, 63, 1328, 360, 14740, 367, 450, 82, 334, 67, 4176, 6365, 3171, 5, 5772, 9, 507, 198, 893, 26, 686, 198, 2190, 14, 912, 8, 5772, 9, 507, 198, 2590, 3743, 14, 2550, 14, 5688, 547, 2360, 69, 26, 686, 198, 2190, 14, 1813, 14, 19092, 342, 686, 198, 2190, 14, 500, 63, 1328, 8, 797, 9, 686, 198, 1757, 360, 5772, 63, 9634, 26, 450, 82, 5956, 69, 9, 507, 198, 2836, 26, 686, 198, 692, 3743, 14, 1813, 459, 12206, 2565, 1585, 198, 2190, 14, 500, 63, 1328, 8, 2190, 14, 1813, 14, 362, 63, 7088, 360, 12206, 1333, 1585, 198, 2190, 14, 1813, 459, 6790, 1193, 540, 63, 12206, 13784, 5772, 1585, 198, 4785, 686, 198, 2190, 14, 500, 63, 1328, 8, 797, 9, 199, 198, 2836, 26, 507, 198, 2190, 14, 16208, 360, 15153, 440, 7908, 282, 286, 4176, 6365, 10916, 199, 318, 1511, 8, 2992, 304, 199, 198, 2992, 14, 912, 63, 6664, 63, 2537, 360, 9634, 63, 4856, 647, 358, 199, 198, 2966, 17327, 63, 5772, 199, 198, 1506, 63, 3246, 29, 7535, 14, 324, 24155, 63, 1274, 63, 3246, 342, 199, 198, 13893, 63, 5772, 63, 513, 29, 9634, 63, 5772, 59, 1506, 63, 3246, 315, 17327, 63, 5772, 436, 1900, 63, 3246, 503, 5121, 69, 1879, 418, 199, 198, 396, 63, 509, 63, 5772, 534, 1987, 904, 8, 13893, 63, 5772, 63, 513, 9, 199, 198, 9634, 63, 5772, 63, 3291, 29, 2992, 14, 525, 63, 1422, 63, 923, 360, 35, 4176, 27154, 8394, 358, 199, 198, 9634, 63, 5772, 63, 3291, 14, 525, 63, 1422, 4517, 1074, 13, 9634, 13, 5772, 297, 885, 5961, 83, 6808, 396, 63, 509, 63, 5772, 12, 3437, 534, 3314, 642, 4298, 4366, 83, 9, 314, 2569, 445, 4176, 27154, 911, 506, 7923, 701, 849, 26, 2071, 83, 4507, 2840, 1506, 63, 3246, 12, 396, 63, 509, 63, 5772, 395, 2614, 628, 1074, 63, 9634, 63, 5772, 531, 199, 198, 509, 671, 315, 511, 63, 509, 63, 5772, 14, 1294, 837, 507, 198, 2992, 14, 912, 3508, 83, 5956, 88, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Ryanglambert/pybrain
pybrain/rl/environments/environment.py
31
1584
__author__ = 'Tom Schaul, tom@idsia.ch' from pybrain.utilities import abstractMethod class Environment(object): """ The general interface for whatever we would like to model, learn about, predict, or simply interact in. We can perform actions, and access (partial) observations. """ # the number of action values the environment accepts indim = 0 # the number of sensor values the environment produces outdim = 0 # discrete state space discreteStates = False # discrete action space discreteActions = False # number of possible actions for discrete action space numActions = None def getSensors(self): """ the currently visible state of the world (the observation may be stochastic - repeated calls returning different values) :rtype: by default, this is assumed to be a numpy array of doubles :note: This function is abstract and has to be implemented. """ abstractMethod() def performAction(self, action): """ perform an action on the world that changes it's internal state (maybe stochastically). :key action: an action that should be executed in the Environment. :type action: by default, this is assumed to be a numpy array of doubles :note: This function is abstract and has to be implemented. """ abstractMethod() def reset(self): """ Most environments will implement this optional method that allows for reinitialization. """
bsd-3-clause
[ 363, 2502, 363, 275, 283, 52, 676, 428, 9518, 348, 12, 370, 77, 32, 344, 10971, 14, 335, 7, 199, 199, 504, 1134, 22246, 14, 16355, 492, 9006, 3767, 421, 199, 533, 9711, 8, 785, 304, 272, 408, 710, 8605, 3217, 367, 15685, 781, 3955, 2839, 370, 1402, 12, 12537, 3595, 12, 267, 12610, 12, 503, 9329, 17232, 315, 14, 2136, 883, 5147, 5445, 12, 436, 2879, 267, 334, 6672, 9, 19739, 14, 272, 408, 339, 327, 314, 1329, 402, 1595, 1338, 314, 3734, 11479, 272, 2539, 77, 275, 378, 339, 327, 314, 1329, 402, 8778, 1338, 314, 3734, 16904, 272, 734, 3572, 275, 378, 339, 327, 24635, 1174, 4601, 272, 24635, 18010, 275, 756, 339, 327, 24635, 1595, 4601, 272, 24635, 9303, 275, 756, 339, 327, 1329, 402, 3962, 5445, 367, 24635, 1595, 4601, 272, 1967, 9303, 275, 488, 339, 347, 664, 51, 17564, 8, 277, 304, 267, 408, 314, 5544, 8917, 1174, 402, 314, 6701, 334, 1589, 20038, 1443, 506, 288, 26123, 21913, 446, 10877, 4882, 8152, 3365, 1338, 9, 953, 520, 4500, 26, 701, 849, 12, 642, 365, 10826, 370, 506, 282, 2680, 1625, 402, 4270, 83, 288, 520, 4610, 26, 961, 805, 365, 9006, 436, 965, 370, 506, 6366, 14, 267, 408, 267, 9006, 3767, 342, 339, 347, 5147, 3310, 8, 277, 12, 1595, 304, 267, 408, 5147, 376, 1595, 641, 314, 6701, 626, 4493, 652, 1159, 5007, 1174, 334, 11853, 288, 26123, 335, 1810, 7288, 680, 288, 520, 498, 1595, 26, 376, 1595, 626, 1077, 506, 7934, 315, 314, 9711, 14, 288, 520, 466, 1595, 26, 701, 849, 12, 642, 365, 10826, 370, 506, 282, 2680, 1625, 402, 4270, 83, 288, 520, 4610, 26, 961, 805, 365, 9006, 436, 965, 370, 506, 6366, 14, 267, 408, 267, 9006, 3767, 342, 339, 347, 5305, 8, 277, 304, 267, 408, 17536, 22196, 911, 5669, 642, 2716, 1083, 626, 6127, 367, 288, 295, 27876, 14, 267, 408, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2502, 363, 275, 283, 52, 676, 428, 9518, 348, 12, 370, 77, 32, 344, 10971, 14, 335, 7, 199, 199, 504, 1134, 22246, 14, 16355, 492, 9006, 3767, 421, 199, 533, 9711, 8, 785, 304, 272, 408, 710, 8605, 3217, 367, 15685, 781, 3955, 2839, 370, 1402, 12, 12537, 3595, 12, 267, 12610, 12, 503, 9329, 17232, 315, 14, 2136, 883, 5147, 5445, 12, 436, 2879, 267, 334, 6672, 9, 19739, 14, 272, 408, 339, 327, 314, 1329, 402, 1595, 1338, 314, 3734, 11479, 272, 2539, 77, 275, 378, 339, 327, 314, 1329, 402, 8778, 1338, 314, 3734, 16904, 272, 734, 3572, 275, 378, 339, 327, 24635, 1174, 4601, 272, 24635, 18010, 275, 756, 339, 327, 24635, 1595, 4601, 272, 24635, 9303, 275, 756, 339, 327, 1329, 402, 3962, 5445, 367, 24635, 1595, 4601, 272, 1967, 9303, 275, 488, 339, 347, 664, 51, 17564, 8, 277, 304, 267, 408, 314, 5544, 8917, 1174, 402, 314, 6701, 334, 1589, 20038, 1443, 506, 288, 26123, 21913, 446, 10877, 4882, 8152, 3365, 1338, 9, 953, 520, 4500, 26, 701, 849, 12, 642, 365, 10826, 370, 506, 282, 2680, 1625, 402, 4270, 83, 288, 520, 4610, 26, 961, 805, 365, 9006, 436, 965, 370, 506, 6366, 14, 267, 408, 267, 9006, 3767, 342, 339, 347, 5147, 3310, 8, 277, 12, 1595, 304, 267, 408, 5147, 376, 1595, 641, 314, 6701, 626, 4493, 652, 1159, 5007, 1174, 334, 11853, 288, 26123, 335, 1810, 7288, 680, 288, 520, 498, 1595, 26, 376, 1595, 626, 1077, 506, 7934, 315, 314, 9711, 14, 288, 520, 466, 1595, 26, 701, 849, 12, 642, 365, 10826, 370, 506, 282, 2680, 1625, 402, 4270, 83, 288, 520, 4610, 26, 961, 805, 365, 9006, 436, 965, 370, 506, 6366, 14, 267, 408, 267, 9006, 3767, 342, 339, 347, 5305, 8, 277, 304, 267, 408, 17536, 22196, 911, 5669, 642, 2716, 1083, 626, 6127, 367, 288, 295, 27876, 14, 267, 408, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ex-contention.py
11261
1486
# futex contention # (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com> # Licensed under the terms of the GNU GPL License version 2 # # Translation of: # # http://sourceware.org/systemtap/wiki/WSFutexContention # # to perf python scripting. # # Measures futex contention import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Util import * process_names = {} thread_thislock = {} thread_blocktime = {} lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time process_names = {} # long-lived pid-to-execname mapping def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, nr, uaddr, op, val, utime, uaddr2, val3): cmd = op & FUTEX_CMD_MASK if cmd != FUTEX_WAIT: return # we don't care about originators of WAKE events process_names[tid] = comm thread_thislock[tid] = uaddr thread_blocktime[tid] = nsecs(s, ns) def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, nr, ret): if thread_blocktime.has_key(tid): elapsed = nsecs(s, ns) - thread_blocktime[tid] add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) del thread_blocktime[tid] del thread_thislock[tid] def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): for (tid, lock) in lock_waits: min, max, avg, count = lock_waits[tid, lock] print "%s[%d] lock %x contended %d times, %d avg ns" % \ (process_names[tid], tid, lock, count, avg)
gpl-2.0
[ 3, 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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, 0, 0, 0, 0 ]
lihui7115/ChromiumGStreamerBackend
tools/compile_test/compile_test.py
159
1781
#!/usr/bin/env python # Copyright (c) 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Tries to compile given code, produces different output depending on success. This is similar to checks done by ./configure scripts. """ import optparse import os import shutil import subprocess import sys import tempfile def DoMain(argv): parser = optparse.OptionParser() parser.add_option('--code') parser.add_option('--run-linker', action='store_true') parser.add_option('--on-success', default='') parser.add_option('--on-failure', default='') options, args = parser.parse_args(argv) if not options.code: parser.error('Missing required --code switch.') # The environment variable might expand to a string with spaces, # e.g. "ccache g++". Convert it to a list suitable for argv. cxx = os.environ.get('CXX', 'g++').split() tmpdir = tempfile.mkdtemp() try: cxx_path = os.path.join(tmpdir, 'test.cc') with open(cxx_path, 'w') as f: f.write(options.code.decode('string-escape')) o_path = os.path.join(tmpdir, 'test.o') cxx_cmdline = cxx + [cxx_path, '-o', o_path] if not options.run_linker: cxx_cmdline.append('-c') # Pass remaining arguments to the compiler. cxx_cmdline += args cxx_popen = subprocess.Popen(cxx_cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cxx_stdout, cxx_stderr = cxx_popen.communicate() if cxx_popen.returncode == 0: print options.on_success else: print options.on_failure finally: shutil.rmtree(tmpdir) return 0 if __name__ == '__main__': sys.exit(DoMain(sys.argv[1:]))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 52, 1996, 370, 6555, 1627, 1233, 12, 16904, 3365, 1072, 10298, 641, 3182, 14, 199, 199, 2765, 365, 8545, 370, 5920, 4224, 701, 16605, 6472, 10554, 14, 199, 624, 421, 199, 646, 8691, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 421, 199, 318, 4226, 6756, 8, 3020, 304, 523, 1798, 275, 8691, 14, 14553, 342, 523, 1798, 14, 525, 63, 1422, 4517, 600, 358, 523, 1798, 14, 525, 63, 1422, 4517, 1065, 13, 20311, 297, 1595, 534, 1617, 63, 2052, 358, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 3742, 297, 849, 13275, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 5328, 297, 849, 13275, 819, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 819, 340, 440, 1511, 14, 600, 26, 272, 1798, 14, 705, 360, 7718, 1415, 1553, 600, 6258, 2659, 819, 327, 710, 3734, 1750, 5594, 6544, 370, 282, 1059, 543, 7883, 12, 523, 327, 325, 14, 71, 14, 298, 67, 1637, 486, 4176, 1674, 7905, 652, 370, 282, 769, 11233, 367, 9238, 14, 523, 17327, 275, 747, 14, 2314, 14, 362, 360, 12206, 297, 283, 71, 4176, 1959, 1294, 342, 819, 12885, 275, 5549, 14, 11983, 342, 523, 862, 26, 272, 17327, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 2055, 358, 272, 543, 1551, 8, 9634, 63, 515, 12, 283, 87, 358, 465, 289, 26, 489, 289, 14, 952, 8, 1419, 14, 600, 14, 2708, 360, 875, 13, 3765, 1333, 339, 312, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 79, 358, 339, 17327, 63, 15612, 275, 17327, 435, 359, 9634, 63, 515, 12, 2475, 79, 297, 312, 63, 515, 61, 272, 340, 440, 1511, 14, 1065, 63, 20311, 26, 489, 17327, 63, 15612, 14, 740, 3654, 67, 358, 272, 327, 8325, 7971, 2368, 370, 314, 6365, 14, 272, 17327, 63, 15612, 847, 1249, 272, 17327, 63, 12207, 275, 3873, 14, 7942, 8, 9634, 63, 15612, 12, 639, 3839, 29, 5781, 14, 6089, 12, 639, 4635, 29, 5781, 14, 6089, 9, 272, 17327, 63, 2703, 12, 17327, 63, 3083, 275, 17327, 63, 12207, 14, 10664, 342, 272, 340, 17327, 63, 12207, 14, 9913, 508, 378, 26, 489, 870, 1511, 14, 265, 63, 3742, 272, 587, 26, 489, 870, 1511, 14, 265, 63, 5328, 523, 3753, 26, 272, 5145, 14, 9242, 8, 8616, 9, 819, 372, 378, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 2585, 6756, 8, 1274, 14, 3020, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 52, 1996, 370, 6555, 1627, 1233, 12, 16904, 3365, 1072, 10298, 641, 3182, 14, 199, 199, 2765, 365, 8545, 370, 5920, 4224, 701, 16605, 6472, 10554, 14, 199, 624, 421, 199, 646, 8691, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 421, 199, 318, 4226, 6756, 8, 3020, 304, 523, 1798, 275, 8691, 14, 14553, 342, 523, 1798, 14, 525, 63, 1422, 4517, 600, 358, 523, 1798, 14, 525, 63, 1422, 4517, 1065, 13, 20311, 297, 1595, 534, 1617, 63, 2052, 358, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 3742, 297, 849, 13275, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 5328, 297, 849, 13275, 819, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 819, 340, 440, 1511, 14, 600, 26, 272, 1798, 14, 705, 360, 7718, 1415, 1553, 600, 6258, 2659, 819, 327, 710, 3734, 1750, 5594, 6544, 370, 282, 1059, 543, 7883, 12, 523, 327, 325, 14, 71, 14, 298, 67, 1637, 486, 4176, 1674, 7905, 652, 370, 282, 769, 11233, 367, 9238, 14, 523, 17327, 275, 747, 14, 2314, 14, 362, 360, 12206, 297, 283, 71, 4176, 1959, 1294, 342, 819, 12885, 275, 5549, 14, 11983, 342, 523, 862, 26, 272, 17327, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 2055, 358, 272, 543, 1551, 8, 9634, 63, 515, 12, 283, 87, 358, 465, 289, 26, 489, 289, 14, 952, 8, 1419, 14, 600, 14, 2708, 360, 875, 13, 3765, 1333, 339, 312, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 79, 358, 339, 17327, 63, 15612, 275, 17327, 435, 359, 9634, 63, 515, 12, 2475, 79, 297, 312, 63, 515, 61, 272, 340, 440, 1511, 14, 1065, 63, 20311, 26, 489, 17327, 63, 15612, 14, 740, 3654, 67, 358, 272, 327, 8325, 7971, 2368, 370, 314, 6365, 14, 272, 17327, 63, 15612, 847, 1249, 272, 17327, 63, 12207, 275, 3873, 14, 7942, 8, 9634, 63, 15612, 12, 639, 3839, 29, 5781, 14, 6089, 12, 639, 4635, 29, 5781, 14, 6089, 9, 272, 17327, 63, 2703, 12, 17327, 63, 3083, 275, 17327, 63, 12207, 14, 10664, 342, 272, 340, 17327, 63, 12207, 14, 9913, 508, 378, 26, 489, 870, 1511, 14, 265, 63, 3742, 272, 587, 26, 489, 870, 1511, 14, 265, 63, 5328, 523, 3753, 26, 272, 5145, 14, 9242, 8, 8616, 9, 819, 372, 378, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 2585, 6756, 8, 1274, 14, 3020, 59, 17, 16720, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tinloaf/home-assistant
tests/components/light/test_init.py
5
17230
"""The tests for the Light component.""" # pylint: disable=protected-access import unittest import unittest.mock as mock import os from io import StringIO import pytest from homeassistant import core, loader from homeassistant.exceptions import Unauthorized from homeassistant.setup import setup_component, async_setup_component from homeassistant.const import ( ATTR_ENTITY_ID, STATE_ON, STATE_OFF, CONF_PLATFORM, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE, ATTR_SUPPORTED_FEATURES) from homeassistant.components import light from homeassistant.helpers.intent import IntentHandleError from tests.common import ( async_mock_service, mock_service, get_test_home_assistant, mock_storage) from tests.components.light import common class TestLight(unittest.TestCase): """Test the light module.""" # pylint: disable=invalid-name def setUp(self): """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant() # pylint: disable=invalid-name def tearDown(self): """Stop everything that was started.""" self.hass.stop() user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) if os.path.isfile(user_light_file): os.remove(user_light_file) def test_methods(self): """Test if methods call the services as expected.""" # Test is_on self.hass.states.set('light.test', STATE_ON) assert light.is_on(self.hass, 'light.test') self.hass.states.set('light.test', STATE_OFF) assert not light.is_on(self.hass, 'light.test') self.hass.states.set(light.ENTITY_ID_ALL_LIGHTS, STATE_ON) assert light.is_on(self.hass) self.hass.states.set(light.ENTITY_ID_ALL_LIGHTS, STATE_OFF) assert not light.is_on(self.hass) # Test turn_on turn_on_calls = mock_service( self.hass, light.DOMAIN, SERVICE_TURN_ON) common.turn_on( self.hass, entity_id='entity_id_val', transition='transition_val', brightness='brightness_val', rgb_color='rgb_color_val', xy_color='xy_color_val', profile='profile_val', color_name='color_name_val', white_value='white_val') self.hass.block_till_done() assert 1 == len(turn_on_calls) call = turn_on_calls[-1] assert light.DOMAIN == call.domain assert SERVICE_TURN_ON == call.service assert 'entity_id_val' == call.data.get(ATTR_ENTITY_ID) assert 'transition_val' == call.data.get(light.ATTR_TRANSITION) assert 'brightness_val' == call.data.get(light.ATTR_BRIGHTNESS) assert 'rgb_color_val' == call.data.get(light.ATTR_RGB_COLOR) assert 'xy_color_val' == call.data.get(light.ATTR_XY_COLOR) assert 'profile_val' == call.data.get(light.ATTR_PROFILE) assert 'color_name_val' == call.data.get(light.ATTR_COLOR_NAME) assert 'white_val' == call.data.get(light.ATTR_WHITE_VALUE) # Test turn_off turn_off_calls = mock_service( self.hass, light.DOMAIN, SERVICE_TURN_OFF) common.turn_off( self.hass, entity_id='entity_id_val', transition='transition_val') self.hass.block_till_done() assert 1 == len(turn_off_calls) call = turn_off_calls[-1] assert light.DOMAIN == call.domain assert SERVICE_TURN_OFF == call.service assert 'entity_id_val' == call.data[ATTR_ENTITY_ID] assert 'transition_val' == call.data[light.ATTR_TRANSITION] # Test toggle toggle_calls = mock_service( self.hass, light.DOMAIN, SERVICE_TOGGLE) common.toggle( self.hass, entity_id='entity_id_val', transition='transition_val') self.hass.block_till_done() assert 1 == len(toggle_calls) call = toggle_calls[-1] assert light.DOMAIN == call.domain assert SERVICE_TOGGLE == call.service assert 'entity_id_val' == call.data[ATTR_ENTITY_ID] assert 'transition_val' == call.data[light.ATTR_TRANSITION] def test_services(self): """Test the provided services.""" platform = loader.get_component(self.hass, 'light.test') platform.init() assert setup_component(self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}}) dev1, dev2, dev3 = platform.DEVICES # Test init assert light.is_on(self.hass, dev1.entity_id) assert not light.is_on(self.hass, dev2.entity_id) assert not light.is_on(self.hass, dev3.entity_id) # Test basic turn_on, turn_off, toggle services common.turn_off(self.hass, entity_id=dev1.entity_id) common.turn_on(self.hass, entity_id=dev2.entity_id) self.hass.block_till_done() assert not light.is_on(self.hass, dev1.entity_id) assert light.is_on(self.hass, dev2.entity_id) # turn on all lights common.turn_on(self.hass) self.hass.block_till_done() assert light.is_on(self.hass, dev1.entity_id) assert light.is_on(self.hass, dev2.entity_id) assert light.is_on(self.hass, dev3.entity_id) # turn off all lights common.turn_off(self.hass) self.hass.block_till_done() assert not light.is_on(self.hass, dev1.entity_id) assert not light.is_on(self.hass, dev2.entity_id) assert not light.is_on(self.hass, dev3.entity_id) # toggle all lights common.toggle(self.hass) self.hass.block_till_done() assert light.is_on(self.hass, dev1.entity_id) assert light.is_on(self.hass, dev2.entity_id) assert light.is_on(self.hass, dev3.entity_id) # toggle all lights common.toggle(self.hass) self.hass.block_till_done() assert not light.is_on(self.hass, dev1.entity_id) assert not light.is_on(self.hass, dev2.entity_id) assert not light.is_on(self.hass, dev3.entity_id) # Ensure all attributes process correctly common.turn_on(self.hass, dev1.entity_id, transition=10, brightness=20, color_name='blue') common.turn_on( self.hass, dev2.entity_id, rgb_color=(255, 255, 255), white_value=255) common.turn_on(self.hass, dev3.entity_id, xy_color=(.4, .6)) self.hass.block_till_done() _, data = dev1.last_call('turn_on') assert { light.ATTR_TRANSITION: 10, light.ATTR_BRIGHTNESS: 20, light.ATTR_HS_COLOR: (240, 100), } == data _, data = dev2.last_call('turn_on') assert { light.ATTR_HS_COLOR: (0, 0), light.ATTR_WHITE_VALUE: 255, } == data _, data = dev3.last_call('turn_on') assert { light.ATTR_HS_COLOR: (71.059, 100), } == data # One of the light profiles prof_name, prof_h, prof_s, prof_bri = 'relax', 35.932, 69.412, 144 # Test light profiles common.turn_on(self.hass, dev1.entity_id, profile=prof_name) # Specify a profile and a brightness attribute to overwrite it common.turn_on( self.hass, dev2.entity_id, profile=prof_name, brightness=100) self.hass.block_till_done() _, data = dev1.last_call('turn_on') assert { light.ATTR_BRIGHTNESS: prof_bri, light.ATTR_HS_COLOR: (prof_h, prof_s), } == data _, data = dev2.last_call('turn_on') assert { light.ATTR_BRIGHTNESS: 100, light.ATTR_HS_COLOR: (prof_h, prof_s), } == data # Test bad data common.turn_on(self.hass) common.turn_on(self.hass, dev1.entity_id, profile="nonexisting") common.turn_on(self.hass, dev2.entity_id, xy_color=["bla-di-bla", 5]) common.turn_on(self.hass, dev3.entity_id, rgb_color=[255, None, 2]) self.hass.block_till_done() _, data = dev1.last_call('turn_on') assert {} == data _, data = dev2.last_call('turn_on') assert {} == data _, data = dev3.last_call('turn_on') assert {} == data # faulty attributes will not trigger a service call common.turn_on( self.hass, dev1.entity_id, profile=prof_name, brightness='bright') common.turn_on( self.hass, dev1.entity_id, rgb_color='yellowish') common.turn_on( self.hass, dev2.entity_id, white_value='high') self.hass.block_till_done() _, data = dev1.last_call('turn_on') assert {} == data _, data = dev2.last_call('turn_on') assert {} == data def test_broken_light_profiles(self): """Test light profiles.""" platform = loader.get_component(self.hass, 'light.test') platform.init() user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) # Setup a wrong light file with open(user_light_file, 'w') as user_file: user_file.write('id,x,y,brightness\n') user_file.write('I,WILL,NOT,WORK\n') assert not setup_component( self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}}) def test_light_profiles(self): """Test light profiles.""" platform = loader.get_component(self.hass, 'light.test') platform.init() user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) with open(user_light_file, 'w') as user_file: user_file.write('id,x,y,brightness\n') user_file.write('test,.4,.6,100\n') assert setup_component( self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}} ) dev1, _, _ = platform.DEVICES common.turn_on(self.hass, dev1.entity_id, profile='test') self.hass.block_till_done() _, data = dev1.last_call('turn_on') assert { light.ATTR_HS_COLOR: (71.059, 100), light.ATTR_BRIGHTNESS: 100 } == data def test_default_profiles_group(self): """Test default turn-on light profile for all lights.""" platform = loader.get_component(self.hass, 'light.test') platform.init() user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) real_isfile = os.path.isfile real_open = open def _mock_isfile(path): if path == user_light_file: return True return real_isfile(path) def _mock_open(path): if path == user_light_file: return StringIO(profile_data) return real_open(path) profile_data = "id,x,y,brightness\n" +\ "group.all_lights.default,.4,.6,99\n" with mock.patch('os.path.isfile', side_effect=_mock_isfile): with mock.patch('builtins.open', side_effect=_mock_open): with mock_storage(): assert setup_component( self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}} ) dev, _, _ = platform.DEVICES common.turn_on(self.hass, dev.entity_id) self.hass.block_till_done() _, data = dev.last_call('turn_on') assert { light.ATTR_HS_COLOR: (71.059, 100), light.ATTR_BRIGHTNESS: 99 } == data def test_default_profiles_light(self): """Test default turn-on light profile for a specific light.""" platform = loader.get_component(self.hass, 'light.test') platform.init() user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) real_isfile = os.path.isfile real_open = open def _mock_isfile(path): if path == user_light_file: return True return real_isfile(path) def _mock_open(path): if path == user_light_file: return StringIO(profile_data) return real_open(path) profile_data = "id,x,y,brightness\n" +\ "group.all_lights.default,.3,.5,200\n" +\ "light.ceiling_2.default,.6,.6,100\n" with mock.patch('os.path.isfile', side_effect=_mock_isfile): with mock.patch('builtins.open', side_effect=_mock_open): with mock_storage(): assert setup_component( self.hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: 'test'}} ) dev = next(filter(lambda x: x.entity_id == 'light.ceiling_2', platform.DEVICES)) common.turn_on(self.hass, dev.entity_id) self.hass.block_till_done() _, data = dev.last_call('turn_on') assert { light.ATTR_HS_COLOR: (50.353, 100), light.ATTR_BRIGHTNESS: 100 } == data async def test_intent_set_color(hass): """Test the set color intent.""" hass.states.async_set('light.hello_2', 'off', { ATTR_SUPPORTED_FEATURES: light.SUPPORT_COLOR }) hass.states.async_set('switch.hello', 'off') calls = async_mock_service(hass, light.DOMAIN, light.SERVICE_TURN_ON) hass.helpers.intent.async_register(light.SetIntentHandler()) result = await hass.helpers.intent.async_handle( 'test', light.INTENT_SET, { 'name': { 'value': 'Hello', }, 'color': { 'value': 'blue' } }) await hass.async_block_till_done() assert result.speech['plain']['speech'] == \ 'Changed hello 2 to the color blue' assert len(calls) == 1 call = calls[0] assert call.domain == light.DOMAIN assert call.service == SERVICE_TURN_ON assert call.data.get(ATTR_ENTITY_ID) == 'light.hello_2' assert call.data.get(light.ATTR_RGB_COLOR) == (0, 0, 255) async def test_intent_set_color_tests_feature(hass): """Test the set color intent.""" hass.states.async_set('light.hello', 'off') calls = async_mock_service(hass, light.DOMAIN, light.SERVICE_TURN_ON) hass.helpers.intent.async_register(light.SetIntentHandler()) try: await hass.helpers.intent.async_handle( 'test', light.INTENT_SET, { 'name': { 'value': 'Hello', }, 'color': { 'value': 'blue' } }) assert False, 'handling intent should have raised' except IntentHandleError as err: assert str(err) == 'Entity hello does not support changing colors' assert len(calls) == 0 async def test_intent_set_color_and_brightness(hass): """Test the set color intent.""" hass.states.async_set('light.hello_2', 'off', { ATTR_SUPPORTED_FEATURES: ( light.SUPPORT_COLOR | light.SUPPORT_BRIGHTNESS) }) hass.states.async_set('switch.hello', 'off') calls = async_mock_service(hass, light.DOMAIN, light.SERVICE_TURN_ON) hass.helpers.intent.async_register(light.SetIntentHandler()) result = await hass.helpers.intent.async_handle( 'test', light.INTENT_SET, { 'name': { 'value': 'Hello', }, 'color': { 'value': 'blue' }, 'brightness': { 'value': '20' } }) await hass.async_block_till_done() assert result.speech['plain']['speech'] == \ 'Changed hello 2 to the color blue and 20% brightness' assert len(calls) == 1 call = calls[0] assert call.domain == light.DOMAIN assert call.service == SERVICE_TURN_ON assert call.data.get(ATTR_ENTITY_ID) == 'light.hello_2' assert call.data.get(light.ATTR_RGB_COLOR) == (0, 0, 255) assert call.data.get(light.ATTR_BRIGHTNESS_PCT) == 20 async def test_light_context(hass, hass_admin_user): """Test that light context works.""" assert await async_setup_component(hass, 'light', { 'light': { 'platform': 'test' } }) state = hass.states.get('light.ceiling') assert state is not None await hass.services.async_call('light', 'toggle', { 'entity_id': state.entity_id, }, True, core.Context(user_id=hass_admin_user.id)) state2 = hass.states.get('light.ceiling') assert state2 is not None assert state.state != state2.state assert state2.context.user_id == hass_admin_user.id async def test_light_turn_on_auth(hass, hass_admin_user): """Test that light context works.""" assert await async_setup_component(hass, 'light', { 'light': { 'platform': 'test' } }) state = hass.states.get('light.ceiling') assert state is not None hass_admin_user.mock_policy({}) with pytest.raises(Unauthorized): await hass.services.async_call('light', 'turn_on', { 'entity_id': state.entity_id, }, True, core.Context(user_id=hass_admin_user.id))
apache-2.0
[ 624, 1918, 2295, 367, 314, 29684, 3931, 1041, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 646, 2882, 199, 646, 2882, 14, 1805, 465, 1683, 199, 646, 747, 199, 504, 5890, 492, 5228, 199, 199, 646, 4613, 199, 199, 504, 8846, 492, 6170, 12, 5077, 199, 504, 8846, 14, 3924, 492, 1910, 11497, 199, 504, 8846, 14, 2758, 492, 3272, 63, 3173, 12, 5316, 63, 2758, 63, 3173, 199, 504, 8846, 14, 1297, 492, 334, 272, 10762, 63, 13630, 63, 998, 12, 11377, 63, 615, 12, 11377, 63, 7517, 12, 6392, 63, 17805, 12, 272, 16655, 63, 52, 7648, 63, 615, 12, 16655, 63, 52, 7648, 63, 7517, 12, 16655, 63, 2566, 2916, 906, 12, 10762, 63, 15925, 63, 13313, 9, 199, 504, 8846, 14, 4608, 492, 10540, 199, 504, 8846, 14, 7546, 14, 17456, 492, 1010, 767, 5940, 547, 199, 199, 504, 2295, 14, 2330, 492, 334, 272, 5316, 63, 1805, 63, 1364, 12, 1683, 63, 1364, 12, 664, 63, 396, 63, 4219, 63, 7310, 12, 1683, 63, 3494, 9, 199, 504, 2295, 14, 4608, 14, 4040, 492, 2863, 421, 199, 533, 1379, 16393, 8, 2796, 14, 1746, 304, 272, 408, 774, 314, 10540, 859, 1041, 339, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 347, 3613, 8, 277, 304, 267, 408, 1084, 1536, 7645, 370, 506, 1255, 1380, 2295, 787, 8239, 1041, 267, 291, 14, 5387, 275, 664, 63, 396, 63, 4219, 63, 7310, 342, 339, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 347, 6766, 8, 277, 304, 267, 408, 6293, 8137, 626, 1990, 8239, 1041, 267, 291, 14, 5387, 14, 2379, 342, 398, 922, 63, 4040, 63, 493, 275, 291, 14, 5387, 14, 888, 14, 515, 8, 4040, 14, 21613, 63, 2514, 9472, 63, 3817, 9, 398, 340, 747, 14, 515, 14, 6292, 8, 751, 63, 4040, 63, 493, 304, 288, 747, 14, 2168, 8, 751, 63, 4040, 63, 493, 9, 339, 347, 511, 63, 2474, 8, 277, 304, 267, 408, 774, 340, 3102, 1240, 314, 8500, 465, 1420, 1041, 267, 327, 1379, 365, 63, 265, 267, 291, 14, 5387, 14, 4981, 14, 409, 360, 4040, 14, 396, 297, 11377, 63, 615, 9, 267, 702, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 12, 283, 4040, 14, 396, 358, 398, 291, 14, 5387, 14, 4981, 14, 409, 360, 4040, 14, 396, 297, 11377, 63, 7517, 9, 267, 702, 440, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 12, 283, 4040, 14, 396, 358, 398, 291, 14, 5387, 14, 4981, 14, 409, 8, 4040, 14, 13630, 63, 998, 63, 1761, 63, 21613, 51, 12, 11377, 63, 615, 9, 267, 702, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 9, 398, 291, 14, 5387, 14, 4981, 14, 409, 8, 4040, 14, 13630, 63, 998, 63, 1761, 63, 21613, 51, 12, 11377, 63, 7517, 9, 267, 702, 440, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 9, 398, 327, 1379, 7485, 63, 265, 267, 7485, 63, 265, 63, 5352, 275, 1683, 63, 1364, 8, 288, 291, 14, 5387, 12, 10540, 14, 7378, 12, 16655, 63, 52, 7648, 63, 615, 9, 398, 2863, 14, 353, 63, 265, 8, 288, 291, 14, 5387, 12, 288, 4642, 63, 344, 534, 4502, 63, 344, 63, 637, 297, 288, 14116, 534, 14143, 63, 637, 297, 288, 27702, 534, 22298, 63, 637, 297, 288, 15180, 63, 2326, 534, 10090, 63, 2326, 63, 637, 297, 288, 13222, 63, 2326, 534, 1702, 63, 2326, 63, 637, 297, 288, 4690, 534, 2913, 63, 637, 297, 288, 3164, 63, 354, 534, 2326, 63, 354, 63, 637, 297, 288, 10424, 63, 585, 534, 7510, 63, 637, 358, 398, 291, 14, 5387, 14, 1457, 63, 12587, 63, 4456, 342, 398, 702, 413, 508, 822, 8, 353, 63, 265, 63, 5352, 9, 267, 1240, 275, 7485, 63, 265, 63, 5352, 1988, 17, 61, 398, 702, 10540, 14, 7378, 508, 1240, 14, 2261, 267, 702, 16655, 63, 52, 7648, 63, 615, 508, 1240, 14, 1364, 267, 702, 283, 4502, 63, 344, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 5280, 63, 13630, 63, 998, 9, 267, 702, 283, 14143, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 12191, 12039, 9, 267, 702, 283, 22298, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 30976, 3025, 9, 267, 702, 283, 10090, 63, 2326, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 12067, 63, 7134, 9, 267, 702, 283, 1702, 63, 2326, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 8195, 63, 7134, 9, 267, 702, 283, 2913, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 16632, 9, 267, 702, 283, 2326, 63, 354, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 7134, 63, 2339, 9, 267, 702, 283, 7510, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 18817, 63, 7041, 9, 398, 327, 1379, 7485, 63, 1997, 267, 7485, 63, 1997, 63, 5352, 275, 1683, 63, 1364, 8, 288, 291, 14, 5387, 12, 10540, 14, 7378, 12, 16655, 63, 52, 7648, 63, 7517, 9, 398, 2863, 14, 353, 63, 1997, 8, 288, 291, 14, 5387, 12, 4642, 63, 344, 534, 4502, 63, 344, 63, 637, 297, 14116, 534, 14143, 63, 637, 358, 398, 291, 14, 5387, 14, 1457, 63, 12587, 63, 4456, 342, 398, 702, 413, 508, 822, 8, 353, 63, 1997, 63, 5352, 9, 267, 1240, 275, 7485, 63, 1997, 63, 5352, 1988, 17, 61, 398, 702, 10540, 14, 7378, 508, 1240, 14, 2261, 267, 702, 16655, 63, 52, 7648, 63, 7517, 508, 1240, 14, 1364, 267, 702, 283, 4502, 63, 344, 63, 637, 7, 508, 1240, 14, 576, 59, 5280, 63, 13630, 63, 998, 61, 267, 702, 283, 14143, 63, 637, 7, 508, 1240, 14, 576, 59, 4040, 14, 5280, 63, 12191, 12039, 61, 398, 327, 1379, 19420, 267, 19420, 63, 5352, 275, 1683, 63, 1364, 8, 288, 291, 14, 5387, 12, 10540, 14, 7378, 12, 16655, 63, 2566, 2916, 906, 9, 398, 2863, 14 ]
[ 1918, 2295, 367, 314, 29684, 3931, 1041, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 646, 2882, 199, 646, 2882, 14, 1805, 465, 1683, 199, 646, 747, 199, 504, 5890, 492, 5228, 199, 199, 646, 4613, 199, 199, 504, 8846, 492, 6170, 12, 5077, 199, 504, 8846, 14, 3924, 492, 1910, 11497, 199, 504, 8846, 14, 2758, 492, 3272, 63, 3173, 12, 5316, 63, 2758, 63, 3173, 199, 504, 8846, 14, 1297, 492, 334, 272, 10762, 63, 13630, 63, 998, 12, 11377, 63, 615, 12, 11377, 63, 7517, 12, 6392, 63, 17805, 12, 272, 16655, 63, 52, 7648, 63, 615, 12, 16655, 63, 52, 7648, 63, 7517, 12, 16655, 63, 2566, 2916, 906, 12, 10762, 63, 15925, 63, 13313, 9, 199, 504, 8846, 14, 4608, 492, 10540, 199, 504, 8846, 14, 7546, 14, 17456, 492, 1010, 767, 5940, 547, 199, 199, 504, 2295, 14, 2330, 492, 334, 272, 5316, 63, 1805, 63, 1364, 12, 1683, 63, 1364, 12, 664, 63, 396, 63, 4219, 63, 7310, 12, 1683, 63, 3494, 9, 199, 504, 2295, 14, 4608, 14, 4040, 492, 2863, 421, 199, 533, 1379, 16393, 8, 2796, 14, 1746, 304, 272, 408, 774, 314, 10540, 859, 1041, 339, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 347, 3613, 8, 277, 304, 267, 408, 1084, 1536, 7645, 370, 506, 1255, 1380, 2295, 787, 8239, 1041, 267, 291, 14, 5387, 275, 664, 63, 396, 63, 4219, 63, 7310, 342, 339, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 347, 6766, 8, 277, 304, 267, 408, 6293, 8137, 626, 1990, 8239, 1041, 267, 291, 14, 5387, 14, 2379, 342, 398, 922, 63, 4040, 63, 493, 275, 291, 14, 5387, 14, 888, 14, 515, 8, 4040, 14, 21613, 63, 2514, 9472, 63, 3817, 9, 398, 340, 747, 14, 515, 14, 6292, 8, 751, 63, 4040, 63, 493, 304, 288, 747, 14, 2168, 8, 751, 63, 4040, 63, 493, 9, 339, 347, 511, 63, 2474, 8, 277, 304, 267, 408, 774, 340, 3102, 1240, 314, 8500, 465, 1420, 1041, 267, 327, 1379, 365, 63, 265, 267, 291, 14, 5387, 14, 4981, 14, 409, 360, 4040, 14, 396, 297, 11377, 63, 615, 9, 267, 702, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 12, 283, 4040, 14, 396, 358, 398, 291, 14, 5387, 14, 4981, 14, 409, 360, 4040, 14, 396, 297, 11377, 63, 7517, 9, 267, 702, 440, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 12, 283, 4040, 14, 396, 358, 398, 291, 14, 5387, 14, 4981, 14, 409, 8, 4040, 14, 13630, 63, 998, 63, 1761, 63, 21613, 51, 12, 11377, 63, 615, 9, 267, 702, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 9, 398, 291, 14, 5387, 14, 4981, 14, 409, 8, 4040, 14, 13630, 63, 998, 63, 1761, 63, 21613, 51, 12, 11377, 63, 7517, 9, 267, 702, 440, 10540, 14, 374, 63, 265, 8, 277, 14, 5387, 9, 398, 327, 1379, 7485, 63, 265, 267, 7485, 63, 265, 63, 5352, 275, 1683, 63, 1364, 8, 288, 291, 14, 5387, 12, 10540, 14, 7378, 12, 16655, 63, 52, 7648, 63, 615, 9, 398, 2863, 14, 353, 63, 265, 8, 288, 291, 14, 5387, 12, 288, 4642, 63, 344, 534, 4502, 63, 344, 63, 637, 297, 288, 14116, 534, 14143, 63, 637, 297, 288, 27702, 534, 22298, 63, 637, 297, 288, 15180, 63, 2326, 534, 10090, 63, 2326, 63, 637, 297, 288, 13222, 63, 2326, 534, 1702, 63, 2326, 63, 637, 297, 288, 4690, 534, 2913, 63, 637, 297, 288, 3164, 63, 354, 534, 2326, 63, 354, 63, 637, 297, 288, 10424, 63, 585, 534, 7510, 63, 637, 358, 398, 291, 14, 5387, 14, 1457, 63, 12587, 63, 4456, 342, 398, 702, 413, 508, 822, 8, 353, 63, 265, 63, 5352, 9, 267, 1240, 275, 7485, 63, 265, 63, 5352, 1988, 17, 61, 398, 702, 10540, 14, 7378, 508, 1240, 14, 2261, 267, 702, 16655, 63, 52, 7648, 63, 615, 508, 1240, 14, 1364, 267, 702, 283, 4502, 63, 344, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 5280, 63, 13630, 63, 998, 9, 267, 702, 283, 14143, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 12191, 12039, 9, 267, 702, 283, 22298, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 30976, 3025, 9, 267, 702, 283, 10090, 63, 2326, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 12067, 63, 7134, 9, 267, 702, 283, 1702, 63, 2326, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 8195, 63, 7134, 9, 267, 702, 283, 2913, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 16632, 9, 267, 702, 283, 2326, 63, 354, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 7134, 63, 2339, 9, 267, 702, 283, 7510, 63, 637, 7, 508, 1240, 14, 576, 14, 362, 8, 4040, 14, 5280, 63, 18817, 63, 7041, 9, 398, 327, 1379, 7485, 63, 1997, 267, 7485, 63, 1997, 63, 5352, 275, 1683, 63, 1364, 8, 288, 291, 14, 5387, 12, 10540, 14, 7378, 12, 16655, 63, 52, 7648, 63, 7517, 9, 398, 2863, 14, 353, 63, 1997, 8, 288, 291, 14, 5387, 12, 4642, 63, 344, 534, 4502, 63, 344, 63, 637, 297, 14116, 534, 14143, 63, 637, 358, 398, 291, 14, 5387, 14, 1457, 63, 12587, 63, 4456, 342, 398, 702, 413, 508, 822, 8, 353, 63, 1997, 63, 5352, 9, 267, 1240, 275, 7485, 63, 1997, 63, 5352, 1988, 17, 61, 398, 702, 10540, 14, 7378, 508, 1240, 14, 2261, 267, 702, 16655, 63, 52, 7648, 63, 7517, 508, 1240, 14, 1364, 267, 702, 283, 4502, 63, 344, 63, 637, 7, 508, 1240, 14, 576, 59, 5280, 63, 13630, 63, 998, 61, 267, 702, 283, 14143, 63, 637, 7, 508, 1240, 14, 576, 59, 4040, 14, 5280, 63, 12191, 12039, 61, 398, 327, 1379, 19420, 267, 19420, 63, 5352, 275, 1683, 63, 1364, 8, 288, 291, 14, 5387, 12, 10540, 14, 7378, 12, 16655, 63, 2566, 2916, 906, 9, 398, 2863, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Absimpl/Abstream
kivytest_version2_12_windows/kivy/factory.py
55
5771
''' Factory object ============== The factory can be used to automatically register any class or module and instantiate classes from it anywhere in your project. It is an implementation of the `Factory Pattern <http://en.wikipedia.org/wiki/Factory_pattern>`_. The class list and available modules are automatically generated by setup.py. Example for registering a class/module:: >>> from kivy.factory import Factory >>> Factory.register('Widget', module='kivy.uix.widget') >>> Factory.register('Vector', module='kivy.vector') Example of using the Factory:: >>> from kivy.factory import Factory >>> widget = Factory.Widget(pos=(456,456)) >>> vector = Factory.Vector(9, 2) Example using a class name:: >>> from kivy.factory import Factory >>> Factory.register('MyWidget', cls=MyWidget) By default, the first classname you register via the factory is permanent. If you wish to change the registered class, you need to unregister the classname before you re-assign it:: >>> from kivy.factory import Factory >>> Factory.register('MyWidget', cls=MyWidget) >>> widget = Factory.MyWidget() >>> Factory.unregister('MyWidget') >>> Factory.register('MyWidget', cls=CustomWidget) >>> customWidget = Factory.MyWidget() ''' __all__ = ('Factory', 'FactoryException') from kivy.logger import Logger class FactoryException(Exception): pass class FactoryBase(object): def __init__(self): super(FactoryBase, self).__init__() self.classes = {} def is_template(self, classname): '''Return True if the classname is a template from the :class:`~kivy.lang.Builder`. .. versionadded:: 1.0.5 ''' if classname in self.classes: return self.classes[classname]['is_template'] else: return False def register(self, classname, cls=None, module=None, is_template=False, baseclasses=None, filename=None, warn=False): '''Register a new classname referring to a real class or class definition in a module. Warn, if True will emit a warning message when a class is re-declared. .. versionchanged:: 1.9.0 `warn` was added. .. versionchanged:: 1.7.0 :attr:`baseclasses` and :attr:`filename` added .. versionchanged:: 1.0.5 :attr:`is_template` has been added in 1.0.5. ''' if cls is None and module is None and baseclasses is None: raise ValueError( 'You must specify either cls= or module= or baseclasses =') if classname in self.classes: if warn: info = self.classes[classname] Logger.warning('Factory: Ignored class "{}" re-declaration. ' 'Current - module: {}, cls: {}, baseclass: {}, filename: {}. ' 'Ignored - module: {}, cls: {}, baseclass: {}, filename: {}.'. format(classname, info['module'], info['cls'], info['baseclasses'], info['filename'], module, cls, baseclasses, filename)) return self.classes[classname] = { 'module': module, 'cls': cls, 'is_template': is_template, 'baseclasses': baseclasses, 'filename': filename} def unregister(self, *classnames): '''Unregisters the classnames previously registered via the register method. This allows the same classnames to be re-used in different contexts. .. versionadded:: 1.7.1 ''' for classname in classnames: if classname in self.classes: self.classes.pop(classname) def unregister_from_filename(self, filename): '''Unregister all the factory objects related to the filename passed in the parameter. .. versionadded:: 1.7.0 ''' to_remove = [x for x in self.classes if self.classes[x]['filename'] == filename] for name in to_remove: del self.classes[name] def __getattr__(self, name): classes = self.classes if name not in classes: if name[0] == name[0].lower(): # if trying to access attributes like checking for `bind` # then raise AttributeError raise AttributeError raise FactoryException('Unknown class <%s>' % name) item = classes[name] cls = item['cls'] # No class to return, import the module if cls is None: if item['module']: module = __import__(name=item['module'], fromlist='.') if not hasattr(module, name): raise FactoryException( 'No class named <%s> in module <%s>' % ( name, item['module'])) cls = item['cls'] = getattr(module, name) elif item['baseclasses']: rootwidgets = [] for basecls in item['baseclasses'].split('+'): rootwidgets.append(Factory.get(basecls)) cls = item['cls'] = type(str(name), tuple(rootwidgets), {}) else: raise FactoryException('No information to create the class') return cls get = __getattr__ #: Factory instance to use for getting new classes Factory = FactoryBase() # Now import the file with all registers # automatically generated by build_factory import kivy.factory_registers # NOQA Logger.info('Factory: %d symbols loaded' % len(Factory.classes)) if __name__ == '__main__': Factory.register('Vector', module='kivy.vector') Factory.register('Widget', module='kivy.uix.widget')
mit
[ 2344, 199, 2927, 909, 199, 17224, 199, 199, 1918, 6434, 883, 506, 1202, 370, 5847, 2274, 1263, 1021, 503, 859, 199, 460, 17321, 3992, 687, 652, 26523, 315, 2195, 2199, 14, 2779, 365, 376, 199, 12236, 402, 314, 199, 64, 2927, 27019, 665, 1014, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 2927, 63, 3401, 8637, 3754, 199, 199, 1918, 1021, 769, 436, 2808, 4621, 787, 5847, 4046, 701, 3272, 14, 647, 14, 199, 199, 9846, 367, 2274, 316, 282, 1021, 15, 578, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 23616, 14, 2683, 360, 3339, 297, 859, 534, 16941, 14, 24263, 14, 3440, 358, 272, 1306, 23616, 14, 2683, 360, 3646, 297, 859, 534, 16941, 14, 4106, 358, 199, 199, 9846, 402, 1808, 314, 23616, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 3938, 275, 23616, 14, 3339, 8, 1712, 2687, 11419, 12, 11419, 430, 272, 1306, 5477, 275, 23616, 14, 3646, 8, 25, 12, 499, 9, 199, 199, 9846, 1808, 282, 1021, 536, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 23616, 14, 2683, 360, 5713, 3339, 297, 843, 29, 5713, 3339, 9, 199, 199, 2175, 849, 12, 314, 1642, 15876, 1265, 2274, 4799, 314, 6434, 365, 19860, 14, 199, 3917, 1265, 13809, 370, 1570, 314, 7264, 1021, 12, 1265, 1929, 370, 24369, 314, 199, 19851, 2544, 1265, 295, 13, 5038, 652, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 23616, 14, 2683, 360, 5713, 3339, 297, 843, 29, 5713, 3339, 9, 272, 1306, 3938, 275, 23616, 14, 5713, 3339, 342, 272, 1306, 23616, 14, 18408, 360, 5713, 3339, 358, 272, 1306, 23616, 14, 2683, 360, 5713, 3339, 297, 843, 29, 7223, 3339, 9, 272, 1306, 3537, 3339, 275, 23616, 14, 5713, 3339, 342, 199, 2344, 199, 199, 363, 452, 363, 275, 661, 2927, 297, 283, 2927, 1726, 358, 199, 199, 504, 17227, 14, 2921, 492, 15996, 421, 199, 533, 23616, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 23616, 1563, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 2927, 1563, 12, 291, 2843, 826, 4533, 267, 291, 14, 2888, 275, 1052, 339, 347, 365, 63, 1160, 8, 277, 12, 15876, 304, 267, 1449, 1767, 715, 340, 314, 15876, 365, 282, 1978, 687, 314, 267, 520, 533, 6054, 16941, 14, 4159, 14, 6437, 2313, 398, 2508, 7445, 447, 413, 14, 16, 14, 21, 267, 1449, 267, 340, 15876, 315, 291, 14, 2888, 26, 288, 372, 291, 14, 2888, 59, 19851, 2733, 374, 63, 1160, 418, 267, 587, 26, 288, 372, 756, 339, 347, 2274, 8, 277, 12, 15876, 12, 843, 29, 403, 12, 859, 29, 403, 12, 365, 63, 1160, 29, 797, 12, 326, 1300, 2888, 29, 403, 12, 1788, 29, 403, 12, 7987, 29, 797, 304, 267, 1449, 7099, 282, 892, 15876, 21864, 370, 282, 3363, 1021, 503, 267, 1021, 5492, 315, 282, 859, 14, 644, 1060, 12, 340, 715, 911, 8689, 282, 5721, 1245, 267, 1380, 282, 1021, 365, 295, 13, 13545, 14, 398, 2508, 16434, 447, 413, 14, 25, 14, 16, 288, 658, 4050, 64, 1990, 3483, 14, 398, 2508, 16434, 447, 413, 14, 23, 14, 16, 288, 520, 962, 1705, 1095, 2888, 64, 436, 520, 962, 1705, 1501, 64, 3483, 398, 2508, 16434, 447, 413, 14, 16, 14, 21, 288, 520, 962, 1705, 374, 63, 1160, 64, 965, 2757, 3483, 315, 413, 14, 16, 14, 21, 14, 267, 1449, 267, 340, 843, 365, 488, 436, 859, 365, 488, 436, 1300, 2888, 365, 488, 26, 288, 746, 1722, 8, 355, 283, 5556, 1471, 4165, 1902, 843, 29, 503, 859, 29, 503, 1300, 2888, 275, 358, 267, 340, 15876, 315, 291, 14, 2888, 26, 288, 340, 7987, 26, 355, 2256, 275, 291, 14, 2888, 59, 19851, 61, 355, 15996, 14, 3764, 360, 2927, 26, 27662, 1021, 28168, 295, 13, 15477, 14, 283, 355, 283, 5639, 446, 221, 859, 26, 5479, 843, 26, 5479, 1300, 533, 26, 5479, 1788, 26, 30332, 283, 355, 283, 19399, 2908, 446, 221, 859, 26, 5479, 843, 26, 5479, 1300, 533, 26, 5479, 1788, 26, 1052, 17374, 355, 1475, 8, 19851, 12, 2256, 459, 578, 995, 2256, 459, 1886, 995, 2432, 2256, 459, 1095, 2888, 995, 2256, 459, 1501, 995, 859, 12, 843, 12, 2432, 1300, 2888, 12, 1788, 430, 288, 372, 267, 291, 14, 2888, 59, 19851, 61, 275, 469, 288, 283, 578, 356, 859, 12, 288, 283, 1886, 356, 843, 12, 288, 283, 374, 63, 1160, 356, 365, 63, 1160, 12, 288, 283, 1095, 2888, 356, 1300, 2888, 12, 288, 283, 1501, 356, 1788, 93, 339, 347, 24369, 8, 277, 12, 627, 533, 1247, 304, 267, 1449, 1358, 30792, 314, 1021, 1247, 10889, 7264, 4799, 314, 267, 2274, 1083, 14, 961, 6127, 314, 2011, 1021, 1247, 370, 506, 295, 13, 2972, 315, 267, 3365, 18191, 14, 398, 2508, 7445, 447, 413, 14, 23, 14, 17, 267, 1449, 267, 367, 15876, 315, 1021, 1247, 26, 288, 340, 15876, 315, 291, 14, 2888, 26, 355, 291, 14, 2888, 14, 1935, 8, 19851, 9, 339, 347, 24369, 63, 504, 63, 1501, 8, 277, 12, 1788, 304, 267, 1449, 27419, 1006, 314, 6434, 2251, 4048, 370, 314, 1788, 3032, 315, 267, 314, 2725, 14, 398, 2508, 7445, 447, 413, 14, 23, 14, 16, 267, 1449, 267, 370, 63, 2168, 275, 359, 88, 367, 671, 315, 291, 14, 2888, 2151, 340, 291, 14, 2888, 59, 88, 2733, 1501, 418, 508, 1788, 61, 267, 367, 536, 315, 370, 63, 2168, 26, 288, 2150, 291, 14, 2888, 59, 354, 61, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 3992, 275, 291, 14, 2888, 267, 340, 536, 440, 315, 3992, 26, 288, 340, 536, 59, 16, 61, 508, 536, 59, 16, 1055, 2325, 837, 355, 327, 340, 9936, 370, 2879, 3004, 2839, 7907, 367, 658, 3409, 64, 355, 327, 2066, 746, 4281, 355, 746, 4281, 288, 746, 23616, 1726, 360, 5912, 1021, 21808, 83, 3524, 450, 536, 9, 398, 1242, 275, 3992, 59, 354, 61, 267, 843, 275, 1242, 459, 1886, 418, 398, 327, 3091, 1021, 370, 372, 12, 492, 314, 859, 267, 340, 843, 365, 488, 26, 288, 340, 1242 ]
[ 199, 2927, 909, 199, 17224, 199, 199, 1918, 6434, 883, 506, 1202, 370, 5847, 2274, 1263, 1021, 503, 859, 199, 460, 17321, 3992, 687, 652, 26523, 315, 2195, 2199, 14, 2779, 365, 376, 199, 12236, 402, 314, 199, 64, 2927, 27019, 665, 1014, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 2927, 63, 3401, 8637, 3754, 199, 199, 1918, 1021, 769, 436, 2808, 4621, 787, 5847, 4046, 701, 3272, 14, 647, 14, 199, 199, 9846, 367, 2274, 316, 282, 1021, 15, 578, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 23616, 14, 2683, 360, 3339, 297, 859, 534, 16941, 14, 24263, 14, 3440, 358, 272, 1306, 23616, 14, 2683, 360, 3646, 297, 859, 534, 16941, 14, 4106, 358, 199, 199, 9846, 402, 1808, 314, 23616, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 3938, 275, 23616, 14, 3339, 8, 1712, 2687, 11419, 12, 11419, 430, 272, 1306, 5477, 275, 23616, 14, 3646, 8, 25, 12, 499, 9, 199, 199, 9846, 1808, 282, 1021, 536, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 23616, 14, 2683, 360, 5713, 3339, 297, 843, 29, 5713, 3339, 9, 199, 199, 2175, 849, 12, 314, 1642, 15876, 1265, 2274, 4799, 314, 6434, 365, 19860, 14, 199, 3917, 1265, 13809, 370, 1570, 314, 7264, 1021, 12, 1265, 1929, 370, 24369, 314, 199, 19851, 2544, 1265, 295, 13, 5038, 652, 447, 339, 1306, 687, 17227, 14, 3702, 492, 23616, 272, 1306, 23616, 14, 2683, 360, 5713, 3339, 297, 843, 29, 5713, 3339, 9, 272, 1306, 3938, 275, 23616, 14, 5713, 3339, 342, 272, 1306, 23616, 14, 18408, 360, 5713, 3339, 358, 272, 1306, 23616, 14, 2683, 360, 5713, 3339, 297, 843, 29, 7223, 3339, 9, 272, 1306, 3537, 3339, 275, 23616, 14, 5713, 3339, 342, 199, 2344, 199, 199, 363, 452, 363, 275, 661, 2927, 297, 283, 2927, 1726, 358, 199, 199, 504, 17227, 14, 2921, 492, 15996, 421, 199, 533, 23616, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 23616, 1563, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 2927, 1563, 12, 291, 2843, 826, 4533, 267, 291, 14, 2888, 275, 1052, 339, 347, 365, 63, 1160, 8, 277, 12, 15876, 304, 267, 1449, 1767, 715, 340, 314, 15876, 365, 282, 1978, 687, 314, 267, 520, 533, 6054, 16941, 14, 4159, 14, 6437, 2313, 398, 2508, 7445, 447, 413, 14, 16, 14, 21, 267, 1449, 267, 340, 15876, 315, 291, 14, 2888, 26, 288, 372, 291, 14, 2888, 59, 19851, 2733, 374, 63, 1160, 418, 267, 587, 26, 288, 372, 756, 339, 347, 2274, 8, 277, 12, 15876, 12, 843, 29, 403, 12, 859, 29, 403, 12, 365, 63, 1160, 29, 797, 12, 326, 1300, 2888, 29, 403, 12, 1788, 29, 403, 12, 7987, 29, 797, 304, 267, 1449, 7099, 282, 892, 15876, 21864, 370, 282, 3363, 1021, 503, 267, 1021, 5492, 315, 282, 859, 14, 644, 1060, 12, 340, 715, 911, 8689, 282, 5721, 1245, 267, 1380, 282, 1021, 365, 295, 13, 13545, 14, 398, 2508, 16434, 447, 413, 14, 25, 14, 16, 288, 658, 4050, 64, 1990, 3483, 14, 398, 2508, 16434, 447, 413, 14, 23, 14, 16, 288, 520, 962, 1705, 1095, 2888, 64, 436, 520, 962, 1705, 1501, 64, 3483, 398, 2508, 16434, 447, 413, 14, 16, 14, 21, 288, 520, 962, 1705, 374, 63, 1160, 64, 965, 2757, 3483, 315, 413, 14, 16, 14, 21, 14, 267, 1449, 267, 340, 843, 365, 488, 436, 859, 365, 488, 436, 1300, 2888, 365, 488, 26, 288, 746, 1722, 8, 355, 283, 5556, 1471, 4165, 1902, 843, 29, 503, 859, 29, 503, 1300, 2888, 275, 358, 267, 340, 15876, 315, 291, 14, 2888, 26, 288, 340, 7987, 26, 355, 2256, 275, 291, 14, 2888, 59, 19851, 61, 355, 15996, 14, 3764, 360, 2927, 26, 27662, 1021, 28168, 295, 13, 15477, 14, 283, 355, 283, 5639, 446, 221, 859, 26, 5479, 843, 26, 5479, 1300, 533, 26, 5479, 1788, 26, 30332, 283, 355, 283, 19399, 2908, 446, 221, 859, 26, 5479, 843, 26, 5479, 1300, 533, 26, 5479, 1788, 26, 1052, 17374, 355, 1475, 8, 19851, 12, 2256, 459, 578, 995, 2256, 459, 1886, 995, 2432, 2256, 459, 1095, 2888, 995, 2256, 459, 1501, 995, 859, 12, 843, 12, 2432, 1300, 2888, 12, 1788, 430, 288, 372, 267, 291, 14, 2888, 59, 19851, 61, 275, 469, 288, 283, 578, 356, 859, 12, 288, 283, 1886, 356, 843, 12, 288, 283, 374, 63, 1160, 356, 365, 63, 1160, 12, 288, 283, 1095, 2888, 356, 1300, 2888, 12, 288, 283, 1501, 356, 1788, 93, 339, 347, 24369, 8, 277, 12, 627, 533, 1247, 304, 267, 1449, 1358, 30792, 314, 1021, 1247, 10889, 7264, 4799, 314, 267, 2274, 1083, 14, 961, 6127, 314, 2011, 1021, 1247, 370, 506, 295, 13, 2972, 315, 267, 3365, 18191, 14, 398, 2508, 7445, 447, 413, 14, 23, 14, 17, 267, 1449, 267, 367, 15876, 315, 1021, 1247, 26, 288, 340, 15876, 315, 291, 14, 2888, 26, 355, 291, 14, 2888, 14, 1935, 8, 19851, 9, 339, 347, 24369, 63, 504, 63, 1501, 8, 277, 12, 1788, 304, 267, 1449, 27419, 1006, 314, 6434, 2251, 4048, 370, 314, 1788, 3032, 315, 267, 314, 2725, 14, 398, 2508, 7445, 447, 413, 14, 23, 14, 16, 267, 1449, 267, 370, 63, 2168, 275, 359, 88, 367, 671, 315, 291, 14, 2888, 2151, 340, 291, 14, 2888, 59, 88, 2733, 1501, 418, 508, 1788, 61, 267, 367, 536, 315, 370, 63, 2168, 26, 288, 2150, 291, 14, 2888, 59, 354, 61, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 3992, 275, 291, 14, 2888, 267, 340, 536, 440, 315, 3992, 26, 288, 340, 536, 59, 16, 61, 508, 536, 59, 16, 1055, 2325, 837, 355, 327, 340, 9936, 370, 2879, 3004, 2839, 7907, 367, 658, 3409, 64, 355, 327, 2066, 746, 4281, 355, 746, 4281, 288, 746, 23616, 1726, 360, 5912, 1021, 21808, 83, 3524, 450, 536, 9, 398, 1242, 275, 3992, 59, 354, 61, 267, 843, 275, 1242, 459, 1886, 418, 398, 327, 3091, 1021, 370, 372, 12, 492, 314, 859, 267, 340, 843, 365, 488, 26, 288, 340, 1242, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sanluca/py-acqua
setup.py
1
1902
# -*- coding: iso-8859-15 -*- #Copyright (C) 2005, 2008 Py-Acqua #http://www.pyacqua.net #email: info@pyacqua.net # # #Py-Acqua is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # #Py-Acqua is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Py-Acqua; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os import sys import glob from distutils.core import setup ### def moon_walk (root_dir, repl): packages, data_files = [], [] for dirpath, dirnames, filenames in os.walk (root_dir): for i, dirname in enumerate (dirnames): if dirname.startswith('.'): del dirnames[i] data_files.append(("share/pyacqua/" + repl + dirpath[len(root_dir):], [os.path.join(dirpath, f) for f in filenames])) return data_files if __name__ != "__main__": print moon_walk (sys.argv[1]) else: setup ( name="py-acqua", version="1.0", description="PyAcqua program", author="Francesco Piccinno", author_email="stack.box@gmail.com", url="http://pyacqua.altervista.org", scripts=["src/acqua.py"], package_dir={'pyacqua': 'src'}, packages=['pyacqua'], data_files=moon_walk ("skins", "skins") + moon_walk ("locale", "locale") + [ #("src", glob.glob ("src/*")), ("share/pyacqua/plugins", glob.glob ("plugins/*.py")), ("share/pyacqua/pixmaps", glob.glob ("pixmaps/*")), ("share/pyacqua/tips", ["src/tip_of_the_day_en.txt", "src/tip_of_the_day.txt"]) ] )
gpl-2.0
[ 3, 1882, 2803, 26, 11601, 13, 4830, 13, 1046, 1882, 221, 199, 3, 7384, 334, 35, 9, 11811, 12, 9079, 1611, 13, 1945, 27164, 199, 3, 1014, 921, 1544, 14, 647, 645, 27164, 14, 846, 199, 3, 2123, 26, 2256, 32, 647, 645, 27164, 14, 846, 257, 199, 3, 199, 3, 259, 199, 3, 2713, 13, 1945, 27164, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2713, 13, 1945, 27164, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 1611, 13, 1945, 27164, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 259, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 421, 199, 646, 747, 199, 646, 984, 199, 646, 5739, 199, 504, 7065, 14, 1018, 492, 3272, 199, 199, 5680, 199, 318, 1303, 265, 63, 7757, 334, 1231, 63, 694, 12, 20265, 304, 199, 198, 5154, 12, 666, 63, 1725, 275, 990, 942, 8299, 198, 509, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 334, 1231, 63, 694, 304, 507, 198, 509, 284, 12, 9017, 315, 3874, 334, 694, 1247, 304, 686, 198, 692, 9017, 14, 2460, 26461, 2150, 22310, 59, 73, 61, 686, 198, 576, 63, 1725, 14, 740, 9313, 6251, 15, 647, 645, 27164, 6687, 435, 20265, 435, 20648, 59, 552, 8, 1231, 63, 694, 304, 467, 359, 736, 14, 515, 14, 904, 8, 17254, 12, 289, 9, 367, 289, 315, 6203, 2459, 8299, 198, 1107, 666, 63, 1725, 199, 199, 692, 636, 354, 363, 1137, 4396, 973, 5727, 199, 198, 1361, 1303, 265, 63, 7757, 334, 1274, 14, 3020, 59, 17, 566, 199, 2836, 26, 199, 198, 2758, 334, 199, 198, 354, 628, 647, 13, 645, 27164, 401, 199, 198, 1023, 628, 17, 14, 16, 401, 199, 198, 1802, 628, 2713, 1945, 27164, 2240, 401, 199, 198, 2502, 628, 13848, 13236, 331, 510, 530, 67, 262, 889, 401, 199, 198, 2502, 63, 2123, 628, 2340, 14, 1977, 32, 6799, 14, 957, 401, 199, 198, 633, 628, 1014, 921, 647, 645, 27164, 14, 11858, 433, 1207, 14, 1308, 401, 199, 198, 6429, 6270, 2164, 15, 645, 27164, 14, 647, 2255, 199, 198, 2491, 63, 694, 3713, 647, 645, 27164, 356, 283, 2164, 2267, 199, 198, 5154, 2968, 647, 645, 27164, 995, 199, 198, 576, 63, 1725, 29, 573, 265, 63, 7757, 1689, 1339, 3617, 401, 298, 1339, 3617, 531, 435, 1303, 265, 63, 7757, 1689, 5508, 401, 298, 5508, 531, 435, 359, 507, 198, 3, 480, 2164, 401, 5739, 14, 6463, 1689, 2164, 6331, 8150, 507, 198, 480, 6251, 15, 647, 645, 27164, 15, 5265, 401, 5739, 14, 6463, 1689, 5265, 20362, 647, 8150, 507, 198, 480, 6251, 15, 647, 645, 27164, 15, 6644, 8919, 401, 5739, 14, 6463, 1689, 6644, 8919, 6331, 8150, 507, 198, 480, 6251, 15, 647, 645, 27164, 15, 25842, 401, 2097, 2164, 15, 8996, 63, 1618, 63, 1589, 63, 2977, 63, 287, 14, 2424, 401, 298, 2164, 15, 8996, 63, 1618, 63, 1589, 63, 2977, 14, 2424, 3135, 199, 198, 61, 199, 198, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 11601, 13, 4830, 13, 1046, 1882, 221, 199, 3, 7384, 334, 35, 9, 11811, 12, 9079, 1611, 13, 1945, 27164, 199, 3, 1014, 921, 1544, 14, 647, 645, 27164, 14, 846, 199, 3, 2123, 26, 2256, 32, 647, 645, 27164, 14, 846, 257, 199, 3, 199, 3, 259, 199, 3, 2713, 13, 1945, 27164, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2713, 13, 1945, 27164, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 1611, 13, 1945, 27164, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 259, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 421, 199, 646, 747, 199, 646, 984, 199, 646, 5739, 199, 504, 7065, 14, 1018, 492, 3272, 199, 199, 5680, 199, 318, 1303, 265, 63, 7757, 334, 1231, 63, 694, 12, 20265, 304, 199, 198, 5154, 12, 666, 63, 1725, 275, 990, 942, 8299, 198, 509, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 334, 1231, 63, 694, 304, 507, 198, 509, 284, 12, 9017, 315, 3874, 334, 694, 1247, 304, 686, 198, 692, 9017, 14, 2460, 26461, 2150, 22310, 59, 73, 61, 686, 198, 576, 63, 1725, 14, 740, 9313, 6251, 15, 647, 645, 27164, 6687, 435, 20265, 435, 20648, 59, 552, 8, 1231, 63, 694, 304, 467, 359, 736, 14, 515, 14, 904, 8, 17254, 12, 289, 9, 367, 289, 315, 6203, 2459, 8299, 198, 1107, 666, 63, 1725, 199, 199, 692, 636, 354, 363, 1137, 4396, 973, 5727, 199, 198, 1361, 1303, 265, 63, 7757, 334, 1274, 14, 3020, 59, 17, 566, 199, 2836, 26, 199, 198, 2758, 334, 199, 198, 354, 628, 647, 13, 645, 27164, 401, 199, 198, 1023, 628, 17, 14, 16, 401, 199, 198, 1802, 628, 2713, 1945, 27164, 2240, 401, 199, 198, 2502, 628, 13848, 13236, 331, 510, 530, 67, 262, 889, 401, 199, 198, 2502, 63, 2123, 628, 2340, 14, 1977, 32, 6799, 14, 957, 401, 199, 198, 633, 628, 1014, 921, 647, 645, 27164, 14, 11858, 433, 1207, 14, 1308, 401, 199, 198, 6429, 6270, 2164, 15, 645, 27164, 14, 647, 2255, 199, 198, 2491, 63, 694, 3713, 647, 645, 27164, 356, 283, 2164, 2267, 199, 198, 5154, 2968, 647, 645, 27164, 995, 199, 198, 576, 63, 1725, 29, 573, 265, 63, 7757, 1689, 1339, 3617, 401, 298, 1339, 3617, 531, 435, 1303, 265, 63, 7757, 1689, 5508, 401, 298, 5508, 531, 435, 359, 507, 198, 3, 480, 2164, 401, 5739, 14, 6463, 1689, 2164, 6331, 8150, 507, 198, 480, 6251, 15, 647, 645, 27164, 15, 5265, 401, 5739, 14, 6463, 1689, 5265, 20362, 647, 8150, 507, 198, 480, 6251, 15, 647, 645, 27164, 15, 6644, 8919, 401, 5739, 14, 6463, 1689, 6644, 8919, 6331, 8150, 507, 198, 480, 6251, 15, 647, 645, 27164, 15, 25842, 401, 2097, 2164, 15, 8996, 63, 1618, 63, 1589, 63, 2977, 63, 287, 14, 2424, 401, 298, 2164, 15, 8996, 63, 1618, 63, 1589, 63, 2977, 14, 2424, 3135, 199, 198, 61, 199, 198, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ptoraskar/django
tests/pagination/tests.py
266
13459
from __future__ import unicode_literals import unittest from datetime import datetime from django.core.paginator import ( EmptyPage, InvalidPage, PageNotAnInteger, Paginator, ) from django.test import TestCase from django.utils import six from .custom import ValidAdjacentNumsPaginator from .models import Article class PaginationTests(unittest.TestCase): """ Tests for the Paginator and Page classes. """ def check_paginator(self, params, output): """ Helper method that instantiates a Paginator object from the passed params and then checks that its attributes match the passed output. """ count, num_pages, page_range = output paginator = Paginator(*params) self.check_attribute('count', paginator, count, params) self.check_attribute('num_pages', paginator, num_pages, params) self.check_attribute('page_range', paginator, page_range, params, coerce=list) def check_attribute(self, name, paginator, expected, params, coerce=None): """ Helper method that checks a single attribute and gives a nice error message upon test failure. """ got = getattr(paginator, name) if coerce is not None: got = coerce(got) self.assertEqual(expected, got, "For '%s', expected %s but got %s. Paginator parameters were: %s" % (name, expected, got, params)) def test_paginator(self): """ Tests the paginator attributes using varying inputs. """ nine = [1, 2, 3, 4, 5, 6, 7, 8, 9] ten = nine + [10] eleven = ten + [11] tests = ( # Each item is two tuples: # First tuple is Paginator parameters - object_list, per_page, # orphans, and allow_empty_first_page. # Second tuple is resulting Paginator attributes - count, # num_pages, and page_range. # Ten items, varying orphans, no empty first page. ((ten, 4, 0, False), (10, 3, [1, 2, 3])), ((ten, 4, 1, False), (10, 3, [1, 2, 3])), ((ten, 4, 2, False), (10, 2, [1, 2])), ((ten, 4, 5, False), (10, 2, [1, 2])), ((ten, 4, 6, False), (10, 1, [1])), # Ten items, varying orphans, allow empty first page. ((ten, 4, 0, True), (10, 3, [1, 2, 3])), ((ten, 4, 1, True), (10, 3, [1, 2, 3])), ((ten, 4, 2, True), (10, 2, [1, 2])), ((ten, 4, 5, True), (10, 2, [1, 2])), ((ten, 4, 6, True), (10, 1, [1])), # One item, varying orphans, no empty first page. (([1], 4, 0, False), (1, 1, [1])), (([1], 4, 1, False), (1, 1, [1])), (([1], 4, 2, False), (1, 1, [1])), # One item, varying orphans, allow empty first page. (([1], 4, 0, True), (1, 1, [1])), (([1], 4, 1, True), (1, 1, [1])), (([1], 4, 2, True), (1, 1, [1])), # Zero items, varying orphans, no empty first page. (([], 4, 0, False), (0, 0, [])), (([], 4, 1, False), (0, 0, [])), (([], 4, 2, False), (0, 0, [])), # Zero items, varying orphans, allow empty first page. (([], 4, 0, True), (0, 1, [1])), (([], 4, 1, True), (0, 1, [1])), (([], 4, 2, True), (0, 1, [1])), # Number if items one less than per_page. (([], 1, 0, True), (0, 1, [1])), (([], 1, 0, False), (0, 0, [])), (([1], 2, 0, True), (1, 1, [1])), ((nine, 10, 0, True), (9, 1, [1])), # Number if items equal to per_page. (([1], 1, 0, True), (1, 1, [1])), (([1, 2], 2, 0, True), (2, 1, [1])), ((ten, 10, 0, True), (10, 1, [1])), # Number if items one more than per_page. (([1, 2], 1, 0, True), (2, 2, [1, 2])), (([1, 2, 3], 2, 0, True), (3, 2, [1, 2])), ((eleven, 10, 0, True), (11, 2, [1, 2])), # Number if items one more than per_page with one orphan. (([1, 2], 1, 1, True), (2, 1, [1])), (([1, 2, 3], 2, 1, True), (3, 1, [1])), ((eleven, 10, 1, True), (11, 1, [1])), # Non-integer inputs ((ten, '4', 1, False), (10, 3, [1, 2, 3])), ((ten, '4', 1, False), (10, 3, [1, 2, 3])), ((ten, 4, '1', False), (10, 3, [1, 2, 3])), ((ten, 4, '1', False), (10, 3, [1, 2, 3])), ) for params, output in tests: self.check_paginator(params, output) def test_invalid_page_number(self): """ Tests that invalid page numbers result in the correct exception being raised. """ paginator = Paginator([1, 2, 3], 2) self.assertRaises(InvalidPage, paginator.page, 3) self.assertRaises(PageNotAnInteger, paginator.validate_number, None) self.assertRaises(PageNotAnInteger, paginator.validate_number, 'x') # With no content and allow_empty_first_page=True, 1 is a valid page number paginator = Paginator([], 2) self.assertEqual(paginator.validate_number(1), 1) def test_paginate_misc_classes(self): class CountContainer(object): def count(self): return 42 # Paginator can be passed other objects with a count() method. paginator = Paginator(CountContainer(), 10) self.assertEqual(42, paginator.count) self.assertEqual(5, paginator.num_pages) self.assertEqual([1, 2, 3, 4, 5], list(paginator.page_range)) # Paginator can be passed other objects that implement __len__. class LenContainer(object): def __len__(self): return 42 paginator = Paginator(LenContainer(), 10) self.assertEqual(42, paginator.count) self.assertEqual(5, paginator.num_pages) self.assertEqual([1, 2, 3, 4, 5], list(paginator.page_range)) def check_indexes(self, params, page_num, indexes): """ Helper method that instantiates a Paginator object from the passed params and then checks that the start and end indexes of the passed page_num match those given as a 2-tuple in indexes. """ paginator = Paginator(*params) if page_num == 'first': page_num = 1 elif page_num == 'last': page_num = paginator.num_pages page = paginator.page(page_num) start, end = indexes msg = ("For %s of page %s, expected %s but got %s." " Paginator parameters were: %s") self.assertEqual(start, page.start_index(), msg % ('start index', page_num, start, page.start_index(), params)) self.assertEqual(end, page.end_index(), msg % ('end index', page_num, end, page.end_index(), params)) def test_page_indexes(self): """ Tests that paginator pages have the correct start and end indexes. """ ten = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] tests = ( # Each item is three tuples: # First tuple is Paginator parameters - object_list, per_page, # orphans, and allow_empty_first_page. # Second tuple is the start and end indexes of the first page. # Third tuple is the start and end indexes of the last page. # Ten items, varying per_page, no orphans. ((ten, 1, 0, True), (1, 1), (10, 10)), ((ten, 2, 0, True), (1, 2), (9, 10)), ((ten, 3, 0, True), (1, 3), (10, 10)), ((ten, 5, 0, True), (1, 5), (6, 10)), # Ten items, varying per_page, with orphans. ((ten, 1, 1, True), (1, 1), (9, 10)), ((ten, 1, 2, True), (1, 1), (8, 10)), ((ten, 3, 1, True), (1, 3), (7, 10)), ((ten, 3, 2, True), (1, 3), (7, 10)), ((ten, 3, 4, True), (1, 3), (4, 10)), ((ten, 5, 1, True), (1, 5), (6, 10)), ((ten, 5, 2, True), (1, 5), (6, 10)), ((ten, 5, 5, True), (1, 10), (1, 10)), # One item, varying orphans, no empty first page. (([1], 4, 0, False), (1, 1), (1, 1)), (([1], 4, 1, False), (1, 1), (1, 1)), (([1], 4, 2, False), (1, 1), (1, 1)), # One item, varying orphans, allow empty first page. (([1], 4, 0, True), (1, 1), (1, 1)), (([1], 4, 1, True), (1, 1), (1, 1)), (([1], 4, 2, True), (1, 1), (1, 1)), # Zero items, varying orphans, allow empty first page. (([], 4, 0, True), (0, 0), (0, 0)), (([], 4, 1, True), (0, 0), (0, 0)), (([], 4, 2, True), (0, 0), (0, 0)), ) for params, first, last in tests: self.check_indexes(params, 'first', first) self.check_indexes(params, 'last', last) # When no items and no empty first page, we should get EmptyPage error. self.assertRaises(EmptyPage, self.check_indexes, ([], 4, 0, False), 1, None) self.assertRaises(EmptyPage, self.check_indexes, ([], 4, 1, False), 1, None) self.assertRaises(EmptyPage, self.check_indexes, ([], 4, 2, False), 1, None) def test_page_sequence(self): """ Tests that a paginator page acts like a standard sequence. """ eleven = 'abcdefghijk' page2 = Paginator(eleven, per_page=5, orphans=1).page(2) self.assertEqual(len(page2), 6) self.assertIn('k', page2) self.assertNotIn('a', page2) self.assertEqual(''.join(page2), 'fghijk') self.assertEqual(''.join(reversed(page2)), 'kjihgf') def test_get_page_hook(self): """ Tests that a Paginator subclass can use the ``_get_page`` hook to return an alternative to the standard Page class. """ eleven = 'abcdefghijk' paginator = ValidAdjacentNumsPaginator(eleven, per_page=6) page1 = paginator.page(1) page2 = paginator.page(2) self.assertIsNone(page1.previous_page_number()) self.assertEqual(page1.next_page_number(), 2) self.assertEqual(page2.previous_page_number(), 1) self.assertIsNone(page2.next_page_number()) def test_page_range_iterator(self): """ Paginator.page_range should be an iterator. """ self.assertIsInstance(Paginator([1, 2, 3], 2).page_range, type(six.moves.range(0))) class ModelPaginationTests(TestCase): """ Test pagination with Django model instances """ def setUp(self): # Prepare a list of objects for pagination. for x in range(1, 10): a = Article(headline='Article %s' % x, pub_date=datetime(2005, 7, 29)) a.save() def test_first_page(self): paginator = Paginator(Article.objects.all(), 5) p = paginator.page(1) self.assertEqual("<Page 1 of 2>", six.text_type(p)) self.assertQuerysetEqual(p.object_list, [ "<Article: Article 1>", "<Article: Article 2>", "<Article: Article 3>", "<Article: Article 4>", "<Article: Article 5>" ], ordered=False ) self.assertTrue(p.has_next()) self.assertFalse(p.has_previous()) self.assertTrue(p.has_other_pages()) self.assertEqual(2, p.next_page_number()) self.assertRaises(InvalidPage, p.previous_page_number) self.assertEqual(1, p.start_index()) self.assertEqual(5, p.end_index()) def test_last_page(self): paginator = Paginator(Article.objects.all(), 5) p = paginator.page(2) self.assertEqual("<Page 2 of 2>", six.text_type(p)) self.assertQuerysetEqual(p.object_list, [ "<Article: Article 6>", "<Article: Article 7>", "<Article: Article 8>", "<Article: Article 9>" ], ordered=False ) self.assertFalse(p.has_next()) self.assertTrue(p.has_previous()) self.assertTrue(p.has_other_pages()) self.assertRaises(InvalidPage, p.next_page_number) self.assertEqual(1, p.previous_page_number()) self.assertEqual(6, p.start_index()) self.assertEqual(9, p.end_index()) def test_page_getitem(self): """ Tests proper behavior of a paginator page __getitem__ (queryset evaluation, slicing, exception raised). """ paginator = Paginator(Article.objects.all(), 5) p = paginator.page(1) # Make sure object_list queryset is not evaluated by an invalid __getitem__ call. # (this happens from the template engine when using eg: {% page_obj.has_previous %}) self.assertIsNone(p.object_list._result_cache) self.assertRaises(TypeError, lambda: p['has_previous']) self.assertIsNone(p.object_list._result_cache) self.assertNotIsInstance(p.object_list, list) # Make sure slicing the Page object with numbers and slice objects work. self.assertEqual(p[0], Article.objects.get(headline='Article 1')) self.assertQuerysetEqual(p[slice(2)], [ "<Article: Article 1>", "<Article: Article 2>", ] ) # After __getitem__ is called, object_list is a list self.assertIsInstance(p.object_list, list)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2882, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 1018, 14, 22073, 492, 334, 272, 9630, 3276, 12, 6378, 3276, 12, 10331, 1763, 2493, 2674, 12, 28006, 8566, 12, 199, 9, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 4229, 492, 4821, 2767, 17235, 5667, 83, 23862, 8566, 199, 504, 1275, 992, 492, 8281, 421, 199, 533, 28006, 3155, 2925, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 367, 314, 28006, 8566, 436, 10331, 3992, 14, 272, 408, 339, 347, 1104, 63, 22073, 8, 277, 12, 1862, 12, 1072, 304, 267, 408, 267, 11642, 1083, 626, 9034, 2335, 282, 28006, 8566, 909, 687, 314, 3032, 267, 1862, 436, 2066, 5920, 626, 2399, 3004, 1336, 314, 3032, 1072, 14, 267, 408, 267, 2338, 12, 1967, 63, 5856, 12, 2034, 63, 1842, 275, 1072, 267, 21398, 275, 28006, 8566, 2031, 1162, 9, 267, 291, 14, 1074, 63, 3215, 360, 835, 297, 21398, 12, 2338, 12, 1862, 9, 267, 291, 14, 1074, 63, 3215, 360, 1507, 63, 5856, 297, 21398, 12, 1967, 63, 5856, 12, 1862, 9, 267, 291, 14, 1074, 63, 3215, 360, 1606, 63, 1842, 297, 21398, 12, 2034, 63, 1842, 12, 1862, 12, 19874, 29, 513, 9, 339, 347, 1104, 63, 3215, 8, 277, 12, 536, 12, 21398, 12, 1420, 12, 1862, 12, 19874, 29, 403, 304, 267, 408, 267, 11642, 1083, 626, 5920, 282, 2849, 2225, 436, 10557, 282, 14213, 1125, 267, 1245, 12188, 511, 5988, 14, 267, 408, 267, 4788, 275, 2519, 8, 22073, 12, 536, 9, 267, 340, 19874, 365, 440, 488, 26, 288, 4788, 275, 19874, 8, 7808, 9, 267, 291, 14, 629, 8, 2062, 12, 4788, 12, 288, 298, 1858, 1543, 83, 297, 1420, 450, 83, 1325, 4788, 450, 83, 14, 221, 28006, 8566, 2633, 4898, 26, 450, 83, 2, 288, 450, 334, 354, 12, 1420, 12, 4788, 12, 1862, 430, 339, 347, 511, 63, 22073, 8, 277, 304, 267, 408, 267, 6496, 314, 21398, 3004, 1808, 17083, 316, 4153, 14, 267, 408, 267, 302, 1132, 275, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 61, 267, 16685, 275, 302, 1132, 435, 359, 709, 61, 267, 12993, 1856, 275, 16685, 435, 359, 845, 61, 267, 2295, 275, 334, 288, 327, 7048, 1242, 365, 2877, 6346, 26, 288, 327, 258, 7758, 2008, 365, 28006, 8566, 2633, 446, 909, 63, 513, 12, 1126, 63, 1606, 12, 288, 327, 260, 503, 838, 796, 12, 436, 2040, 63, 1667, 63, 2246, 63, 1606, 14, 288, 327, 258, 16707, 2008, 365, 9183, 28006, 8566, 3004, 446, 2338, 12, 288, 327, 260, 1967, 63, 5856, 12, 436, 2034, 63, 1842, 14, 288, 327, 377, 287, 2974, 12, 17083, 316, 503, 838, 796, 12, 949, 2701, 1642, 2034, 14, 288, 3666, 724, 12, 841, 12, 378, 12, 756, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 413, 12, 756, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 499, 12, 756, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 959, 12, 756, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 1227, 12, 756, 395, 334, 709, 12, 413, 12, 359, 17, 12884, 288, 327, 377, 287, 2974, 12, 17083, 316, 503, 838, 796, 12, 2040, 2701, 1642, 2034, 14, 288, 3666, 724, 12, 841, 12, 378, 12, 715, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 413, 12, 715, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 499, 12, 715, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 959, 12, 715, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 1227, 12, 715, 395, 334, 709, 12, 413, 12, 359, 17, 12884, 288, 327, 7309, 1242, 12, 17083, 316, 503, 838, 796, 12, 949, 2701, 1642, 2034, 14, 288, 334, 779, 17, 467, 841, 12, 378, 12, 756, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 413, 12, 756, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 499, 12, 756, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 327, 7309, 1242, 12, 17083, 316, 503, 838, 796, 12, 2040, 2701, 1642, 2034, 14, 288, 334, 779, 17, 467, 841, 12, 378, 12, 715, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 413, 12, 715, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 499, 12, 715, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 327, 15708, 2974, 12, 17083, 316, 503, 838, 796, 12, 949, 2701, 1642, 2034, 14, 288, 334, 8798, 841, 12, 378, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 288, 334, 8798, 841, 12, 413, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 288, 334, 8798, 841, 12, 499, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 288, 327, 15708, 2974, 12, 17083, 316, 503, 838, 796, 12, 2040, 2701, 1642, 2034, 14, 288, 334, 8798, 841, 12, 378, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 334, 8798, 841, 12, 413, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 334, 8798, 841, 12, 499, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 327, 4860, 340, 2974, 1373, 6656, 2419, 1126, 63, 1606, 14, 288, 334, 8798, 413, 12, 378, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 334, 8798, 413, 12, 378, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2882, 199, 504, 2197, 492, 2197, 199, 199, 504, 1639, 14, 1018, 14, 22073, 492, 334, 272, 9630, 3276, 12, 6378, 3276, 12, 10331, 1763, 2493, 2674, 12, 28006, 8566, 12, 199, 9, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 4229, 492, 4821, 2767, 17235, 5667, 83, 23862, 8566, 199, 504, 1275, 992, 492, 8281, 421, 199, 533, 28006, 3155, 2925, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 367, 314, 28006, 8566, 436, 10331, 3992, 14, 272, 408, 339, 347, 1104, 63, 22073, 8, 277, 12, 1862, 12, 1072, 304, 267, 408, 267, 11642, 1083, 626, 9034, 2335, 282, 28006, 8566, 909, 687, 314, 3032, 267, 1862, 436, 2066, 5920, 626, 2399, 3004, 1336, 314, 3032, 1072, 14, 267, 408, 267, 2338, 12, 1967, 63, 5856, 12, 2034, 63, 1842, 275, 1072, 267, 21398, 275, 28006, 8566, 2031, 1162, 9, 267, 291, 14, 1074, 63, 3215, 360, 835, 297, 21398, 12, 2338, 12, 1862, 9, 267, 291, 14, 1074, 63, 3215, 360, 1507, 63, 5856, 297, 21398, 12, 1967, 63, 5856, 12, 1862, 9, 267, 291, 14, 1074, 63, 3215, 360, 1606, 63, 1842, 297, 21398, 12, 2034, 63, 1842, 12, 1862, 12, 19874, 29, 513, 9, 339, 347, 1104, 63, 3215, 8, 277, 12, 536, 12, 21398, 12, 1420, 12, 1862, 12, 19874, 29, 403, 304, 267, 408, 267, 11642, 1083, 626, 5920, 282, 2849, 2225, 436, 10557, 282, 14213, 1125, 267, 1245, 12188, 511, 5988, 14, 267, 408, 267, 4788, 275, 2519, 8, 22073, 12, 536, 9, 267, 340, 19874, 365, 440, 488, 26, 288, 4788, 275, 19874, 8, 7808, 9, 267, 291, 14, 629, 8, 2062, 12, 4788, 12, 288, 298, 1858, 1543, 83, 297, 1420, 450, 83, 1325, 4788, 450, 83, 14, 221, 28006, 8566, 2633, 4898, 26, 450, 83, 2, 288, 450, 334, 354, 12, 1420, 12, 4788, 12, 1862, 430, 339, 347, 511, 63, 22073, 8, 277, 304, 267, 408, 267, 6496, 314, 21398, 3004, 1808, 17083, 316, 4153, 14, 267, 408, 267, 302, 1132, 275, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 61, 267, 16685, 275, 302, 1132, 435, 359, 709, 61, 267, 12993, 1856, 275, 16685, 435, 359, 845, 61, 267, 2295, 275, 334, 288, 327, 7048, 1242, 365, 2877, 6346, 26, 288, 327, 258, 7758, 2008, 365, 28006, 8566, 2633, 446, 909, 63, 513, 12, 1126, 63, 1606, 12, 288, 327, 260, 503, 838, 796, 12, 436, 2040, 63, 1667, 63, 2246, 63, 1606, 14, 288, 327, 258, 16707, 2008, 365, 9183, 28006, 8566, 3004, 446, 2338, 12, 288, 327, 260, 1967, 63, 5856, 12, 436, 2034, 63, 1842, 14, 288, 327, 377, 287, 2974, 12, 17083, 316, 503, 838, 796, 12, 949, 2701, 1642, 2034, 14, 288, 3666, 724, 12, 841, 12, 378, 12, 756, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 413, 12, 756, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 499, 12, 756, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 959, 12, 756, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 1227, 12, 756, 395, 334, 709, 12, 413, 12, 359, 17, 12884, 288, 327, 377, 287, 2974, 12, 17083, 316, 503, 838, 796, 12, 2040, 2701, 1642, 2034, 14, 288, 3666, 724, 12, 841, 12, 378, 12, 715, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 413, 12, 715, 395, 334, 709, 12, 650, 12, 359, 17, 12, 499, 12, 650, 12884, 288, 3666, 724, 12, 841, 12, 499, 12, 715, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 959, 12, 715, 395, 334, 709, 12, 499, 12, 359, 17, 12, 499, 12884, 288, 3666, 724, 12, 841, 12, 1227, 12, 715, 395, 334, 709, 12, 413, 12, 359, 17, 12884, 288, 327, 7309, 1242, 12, 17083, 316, 503, 838, 796, 12, 949, 2701, 1642, 2034, 14, 288, 334, 779, 17, 467, 841, 12, 378, 12, 756, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 413, 12, 756, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 499, 12, 756, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 327, 7309, 1242, 12, 17083, 316, 503, 838, 796, 12, 2040, 2701, 1642, 2034, 14, 288, 334, 779, 17, 467, 841, 12, 378, 12, 715, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 413, 12, 715, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 334, 779, 17, 467, 841, 12, 499, 12, 715, 395, 334, 17, 12, 413, 12, 359, 17, 12884, 288, 327, 15708, 2974, 12, 17083, 316, 503, 838, 796, 12, 949, 2701, 1642, 2034, 14, 288, 334, 8798, 841, 12, 378, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 288, 334, 8798, 841, 12, 413, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 288, 334, 8798, 841, 12, 499, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 288, 327, 15708, 2974, 12, 17083, 316, 503, 838, 796, 12, 2040, 2701, 1642, 2034, 14, 288, 334, 8798, 841, 12, 378, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 334, 8798, 841, 12, 413, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 334, 8798, 841, 12, 499, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 327, 4860, 340, 2974, 1373, 6656, 2419, 1126, 63, 1606, 14, 288, 334, 8798, 413, 12, 378, 12, 715, 395, 334, 16, 12, 413, 12, 359, 17, 12884, 288, 334, 8798, 413, 12, 378, 12, 756, 395, 334, 16, 12, 378, 12, 3073, 395, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bhermansyah/DRR-datacenter
scripts/misc-boedy1996/glofas_refactor.py
1
6276
import os, sys os.environ.setdefault("DJANGO_SETTINGS_MODULE","geonode.settings") import csv from django.db import connection, connections from django.conf import settings from geodb.models import Glofasintegrated, AfgBasinLvl4GlofasPoint from netCDF4 import Dataset, num2date import numpy as np from django.contrib.gis.geos import Point def getRefactorData(): # f_IN = open("/Users/budi/Documents/iMMAP/DRR-datacenter/scripts/misc-boedy1996/Glofas_Baseline_Output_Adjustment_factor.csv", 'rU') f_IN = open("/home/ubuntu/Glofas_Baseline_Output_Adjustment_factor.csv", 'rU') reader = csv.reader(f_IN) first = True data = {} for row in reader: if first: first = False else: lon = row[2] lat = row[1] # data[lat][lon]['rl2_factor']=row[8] data[lat]={lon:{'rl2_factor':row[8],'rl5_factor':row[9],'rl20_factor':row[10]}} f_IN.close() # print data['67.75']['31.85'] return data def calculate_glofas_params(date): date_arr = date.split('-') filename = getattr(settings, 'GLOFAS_NC_FILES')+date_arr[0]+date_arr[1]+date_arr[2]+"00.nc" # print Glofasintegrated.objects.latest('datadate').date nc = Dataset(filename, 'r', Format='NETCDF4') # get coordinates variables lats = nc.variables['lat'][:] lons = nc.variables['lon'][:] rl2s= nc.variables['rl2'][:] rl5s= nc.variables['rl5'][:] rl20s= nc.variables['rl20'][:] times = nc.variables['time'][:] essemble = nc.variables['ensemble'][:] # convert date, how to store date only strip away time? # print "Converting Dates" units = nc.variables['time'].units dates = num2date (times[:], units=units, calendar='365_day') d = np.array(nc.variables['dis']) # header = ['Latitude', 'Longitude', 'rl2', 'rl5', 'rl20', 'rl2_dis_percent', 'rl2_avg_dis_percent', 'rl5_dis_percent', 'rl5_avg_dis_percent', 'rl20_dis_percent', 'rl20_avg_dis_percent'] times_index=[] for i,j in enumerate(times): times_index.append(i) coord_index = 0 refactor = getRefactorData() for lat, lon, rl2, rl5, rl20 in zip(lats, lons, rl2s, rl5s, rl20s): # print str(lat), str(lon) try: # print refactor[str(lat)][str(lon)] rl2_temp = rl2*float(refactor[str(lat)][str(lon)]['rl2_factor']) rl5_temp = rl5*float(refactor[str(lat)][str(lon)]['rl5_factor']) rl20_temp = rl20*float(refactor[str(lat)][str(lon)]['rl20_factor']) except: rl2_temp = rl2 rl5_temp = rl5 rl20_temp = rl20 rl2 = rl2_temp rl5 = rl5_temp rl20 = rl20_temp # print rl2,rl5,rl20, refactor[str(lat)][str(lon)]['rl2_factor'] data_in = [] data_in.append(lat) data_in.append(lon) data_in.append(rl2) data_in.append(rl5) data_in.append(rl20) rl2_dis_percent = [] rl5_dis_percent = [] rl20_dis_percent = [] rl2_avg_dis = [] rl5_avg_dis = [] rl20_avg_dis = [] for i in times_index: data = d[i,:,coord_index] dis_data = [] for l in data: dis_data.append(l) dis_avg = np.median(dis_data) count = sum(1 for x in data if x>rl2) percent_rl2 = round(float(count)/float(51)*100) rl2_avg_dis.append(round(float(dis_avg)/float(rl2)*100)) rl2_dis_percent.append(percent_rl2) count = sum(1 for x in data if x>rl5) percent_rl5 = round(float(count)/float(51)*100) rl5_avg_dis.append(round(float(dis_avg)/float(rl5)*100)) rl5_dis_percent.append(percent_rl5) count = sum(1 for x in data if x>rl20) percent_rl20 = round(float(count)/float(51)*100) rl20_avg_dis.append(round(float(dis_avg)/float(rl20)*100)) rl20_dis_percent.append(percent_rl20) if i>=19: break # print rl2_avg_dis data_in.append(max(rl2_dis_percent)) temp_avg_dis=[] for index, item in enumerate(rl2_dis_percent): if item == max(rl2_dis_percent): # print index, item temp_avg_dis.append(rl2_avg_dis[index]) data_in.append(max(temp_avg_dis)) rl2_avg_dis_percent = max(temp_avg_dis) data_in.append(max(rl5_dis_percent)) temp_avg_dis=[] for index, item in enumerate(rl5_dis_percent): if item == max(rl5_dis_percent): # print index, item temp_avg_dis.append(rl5_avg_dis[index]) data_in.append(max(temp_avg_dis)) rl5_avg_dis_percent = max(temp_avg_dis) data_in.append(max(rl20_dis_percent)) temp_avg_dis=[] for index, item in enumerate(rl20_dis_percent): if item == max(rl20_dis_percent): # print index, item temp_avg_dis.append(rl20_avg_dis[index]) data_in.append(max(temp_avg_dis)) rl20_avg_dis_percent = max(temp_avg_dis) if coord_index>2035 and max(rl2_dis_percent)>=25: pnt = Point(round(float(lon),2), round(float(lat),2), srid=4326) checkdata = AfgBasinLvl4GlofasPoint.objects.filter(geom__intersects=pnt) for z in checkdata: p = Glofasintegrated(basin_id=z.value, datadate=date, lon=lon, lat=lat, rl2=rl2, rl5=rl5, rl20=rl20, rl2_dis_percent=max(rl2_dis_percent), rl2_avg_dis_percent=rl2_avg_dis_percent, rl5_dis_percent=max(rl5_dis_percent), rl5_avg_dis_percent=rl5_avg_dis_percent, rl20_dis_percent=max(rl20_dis_percent), rl20_avg_dis_percent=rl20_avg_dis_percent) p.save() print coord_index, z.value coord_index = coord_index+1 # print data_in # print Glofasintegrated.objects.filter(datadate=date).count() # if Glofasintegrated.objects.filter(datadate=date).count() == 0 : # Glofasintegrated(datadate=date).save() nc.close() Glofasintegrated.objects.filter(datadate='2017-04-13').delete() calculate_glofas_params('2017-04-13') # px = Glofasintegrated.objects.order_by().values('datadate').distinct() # for i in px: # print str(i['datadate']) # Glofasintegrated.objects.filter(datadate=i['datadate']).delete() # calculate_glofas_params(str(i['datadate']))
gpl-3.0
[ 646, 747, 12, 984, 199, 736, 14, 2314, 14, 5486, 480, 22848, 63, 13931, 63, 10001, 2266, 303, 29118, 14, 1751, 531, 199, 199, 646, 7392, 199, 504, 1639, 14, 697, 492, 1950, 12, 6947, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 2312, 13152, 14, 992, 492, 598, 320, 70, 305, 25323, 972, 12, 437, 9681, 34, 24202, 44, 7300, 20, 39, 320, 70, 305, 3428, 199, 504, 1851, 18967, 20, 492, 20284, 12, 1967, 18, 602, 199, 646, 2680, 465, 980, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 7584, 199, 199, 318, 664, 497, 4778, 1451, 837, 199, 198, 3, 289, 63, 568, 275, 1551, 4769, 12117, 15, 464, 328, 15, 26872, 15, 73, 3218, 1282, 15, 4564, 50, 13, 17770, 15, 6429, 15, 9923, 13, 656, 379, 89, 7155, 22, 15, 39, 320, 70, 305, 63, 1563, 604, 63, 2959, 63, 17977, 434, 63, 4778, 14, 4737, 401, 283, 28978, 358, 199, 198, 70, 63, 568, 275, 1551, 4769, 4219, 15, 21151, 15, 39, 320, 70, 305, 63, 1563, 604, 63, 2959, 63, 17977, 434, 63, 4778, 14, 4737, 401, 283, 28978, 358, 199, 198, 5503, 275, 7392, 14, 5503, 8, 70, 63, 568, 9, 199, 198, 2246, 275, 715, 199, 198, 576, 275, 1052, 421, 198, 509, 1962, 315, 7002, 26, 507, 198, 692, 1642, 26, 686, 198, 2246, 275, 756, 507, 198, 2836, 26, 686, 198, 5298, 275, 1962, 59, 18, 61, 686, 198, 4452, 275, 1962, 59, 17, 61, 6319, 198, 3, 666, 59, 4452, 1527, 5298, 2733, 4308, 18, 63, 4778, 13784, 1143, 59, 24, 61, 686, 198, 576, 59, 4452, 61, 3126, 5298, 26, 1445, 4308, 18, 63, 4778, 356, 1143, 59, 24, 26801, 4308, 21, 63, 4778, 356, 1143, 59, 25, 26801, 4308, 1165, 63, 4778, 356, 1143, 59, 709, 61, 4863, 421, 198, 70, 63, 568, 14, 1600, 342, 199, 198, 3, 870, 666, 459, 1822, 14, 2194, 2545, 2192, 14, 2426, 418, 199, 198, 1107, 666, 199, 199, 318, 8671, 63, 30737, 70, 305, 63, 1162, 8, 602, 304, 339, 1434, 63, 5250, 275, 1434, 14, 1294, 21950, 272, 1788, 275, 2519, 8, 1751, 12, 283, 39, 1484, 38, 1179, 63, 6389, 63, 9472, 358, 11, 602, 63, 5250, 59, 16, 2807, 602, 63, 5250, 59, 17, 2807, 602, 63, 5250, 59, 18, 2807, 2, 383, 14, 7966, 2, 272, 327, 870, 598, 320, 70, 305, 25323, 972, 14, 1462, 14, 7410, 360, 4616, 350, 323, 1959, 602, 339, 12698, 275, 20284, 8, 1501, 12, 283, 82, 297, 9701, 534, 7278, 18967, 20, 358, 339, 327, 664, 8983, 2860, 272, 634, 1956, 275, 12698, 14, 3669, 459, 4452, 418, 5873, 272, 634, 4654, 275, 12698, 14, 3669, 459, 5298, 418, 5873, 339, 25717, 18, 83, 29, 12698, 14, 3669, 459, 4308, 18, 418, 5873, 272, 25717, 21, 83, 29, 12698, 14, 3669, 459, 4308, 21, 418, 5873, 272, 25717, 1165, 83, 29, 12698, 14, 3669, 459, 4308, 1165, 418, 5873, 272, 5431, 275, 12698, 14, 3669, 459, 521, 418, 5873, 272, 9455, 8834, 275, 12698, 14, 3669, 459, 15628, 418, 5873, 339, 327, 3957, 1434, 12, 4212, 370, 3877, 1434, 1454, 6202, 13437, 900, 31, 272, 327, 870, 298, 7619, 1337, 577, 2335, 2, 272, 6204, 275, 12698, 14, 3669, 459, 521, 2278, 5260, 272, 10831, 275, 1967, 18, 602, 334, 4508, 23315, 6204, 29, 5260, 12, 11234, 534, 12664, 63, 2977, 358, 339, 366, 275, 980, 14, 1144, 8, 7966, 14, 3669, 459, 2297, 1105, 272, 327, 1406, 275, 788, 44, 31429, 3786, 297, 283, 9551, 7779, 297, 283, 4308, 18, 297, 283, 4308, 21, 297, 283, 4308, 1165, 297, 283, 4308, 18, 63, 2297, 63, 7045, 297, 283, 4308, 18, 63, 8595, 63, 2297, 63, 7045, 297, 283, 4308, 21, 63, 2297, 63, 7045, 297, 283, 4308, 21, 63, 8595, 63, 2297, 63, 7045, 297, 283, 4308, 1165, 63, 2297, 63, 7045, 297, 283, 4308, 1165, 63, 8595, 63, 2297, 63, 7045, 418, 272, 5431, 63, 1080, 9811, 272, 367, 284, 12, 74, 315, 3874, 8, 4508, 304, 267, 5431, 63, 1080, 14, 740, 8, 73, 9, 339, 11021, 63, 1080, 275, 378, 339, 24200, 275, 664, 497, 4778, 1451, 342, 339, 367, 8396, 12, 6132, 12, 25717, 18, 12, 25717, 21, 12, 25717, 1165, 315, 3482, 8, 76, 1956, 12, 634, 4654, 12, 25717, 18, 83, 12, 25717, 21, 83, 12, 25717, 1165, 83, 304, 1362, 198, 3, 870, 620, 8, 4452, 395, 620, 8, 5298, 9, 19066, 1362, 198, 893, 26, 19066, 198, 3, 870, 24200, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 19066, 198, 4308, 18, 63, 808, 275, 25717, 18, 10, 1609, 8, 264, 4778, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 18, 63, 4778, 1105, 19066, 198, 4308, 21, 63, 808, 275, 25717, 21, 10, 1609, 8, 264, 4778, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 21, 63, 4778, 1105, 19066, 198, 4308, 1165, 63, 808, 275, 25717, 1165, 10, 1609, 8, 264, 4778, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 1165, 63, 4778, 1105, 1362, 198, 2590, 26, 19066, 198, 4308, 18, 63, 808, 275, 25717, 18, 19066, 198, 4308, 21, 63, 808, 275, 25717, 21, 19066, 198, 4308, 1165, 63, 808, 275, 25717, 1165, 2728, 25717, 18, 275, 25717, 18, 63, 808, 267, 25717, 21, 275, 25717, 21, 63, 808, 267, 25717, 1165, 275, 25717, 1165, 63, 808, 398, 327, 870, 25717, 18, 12, 4308, 21, 12, 4308, 1165, 12, 24200, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 18, 63, 4778, 418, 398, 666, 63, 262, 275, 942, 267, 666, 63, 262, 14, 740, 8, 4452, 9, 267, 666, 63, 262, 14, 740, 8, 5298, 9, 267, 666, 63, 262, 14, 740, 8, 4308, 18, 9, 267, 666, 63, 262, 14, 740, 8, 4308, 21, 9, 267, 666, 63, 262, 14, 740, 8, 4308, 1165, 9, 398, 25717, 18, 63, 2297, 63, 7045, 275, 942, 267, 25717, 21, 63, 2297, 63, 7045, 275, 942, 267, 25717, 1165, 63, 2297, 63, 7045, 275, 942, 398, 25717, 18, 63, 8595, 63, 2297 ]
[ 747, 12, 984, 199, 736, 14, 2314, 14, 5486, 480, 22848, 63, 13931, 63, 10001, 2266, 303, 29118, 14, 1751, 531, 199, 199, 646, 7392, 199, 504, 1639, 14, 697, 492, 1950, 12, 6947, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 504, 2312, 13152, 14, 992, 492, 598, 320, 70, 305, 25323, 972, 12, 437, 9681, 34, 24202, 44, 7300, 20, 39, 320, 70, 305, 3428, 199, 504, 1851, 18967, 20, 492, 20284, 12, 1967, 18, 602, 199, 646, 2680, 465, 980, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 7584, 199, 199, 318, 664, 497, 4778, 1451, 837, 199, 198, 3, 289, 63, 568, 275, 1551, 4769, 12117, 15, 464, 328, 15, 26872, 15, 73, 3218, 1282, 15, 4564, 50, 13, 17770, 15, 6429, 15, 9923, 13, 656, 379, 89, 7155, 22, 15, 39, 320, 70, 305, 63, 1563, 604, 63, 2959, 63, 17977, 434, 63, 4778, 14, 4737, 401, 283, 28978, 358, 199, 198, 70, 63, 568, 275, 1551, 4769, 4219, 15, 21151, 15, 39, 320, 70, 305, 63, 1563, 604, 63, 2959, 63, 17977, 434, 63, 4778, 14, 4737, 401, 283, 28978, 358, 199, 198, 5503, 275, 7392, 14, 5503, 8, 70, 63, 568, 9, 199, 198, 2246, 275, 715, 199, 198, 576, 275, 1052, 421, 198, 509, 1962, 315, 7002, 26, 507, 198, 692, 1642, 26, 686, 198, 2246, 275, 756, 507, 198, 2836, 26, 686, 198, 5298, 275, 1962, 59, 18, 61, 686, 198, 4452, 275, 1962, 59, 17, 61, 6319, 198, 3, 666, 59, 4452, 1527, 5298, 2733, 4308, 18, 63, 4778, 13784, 1143, 59, 24, 61, 686, 198, 576, 59, 4452, 61, 3126, 5298, 26, 1445, 4308, 18, 63, 4778, 356, 1143, 59, 24, 26801, 4308, 21, 63, 4778, 356, 1143, 59, 25, 26801, 4308, 1165, 63, 4778, 356, 1143, 59, 709, 61, 4863, 421, 198, 70, 63, 568, 14, 1600, 342, 199, 198, 3, 870, 666, 459, 1822, 14, 2194, 2545, 2192, 14, 2426, 418, 199, 198, 1107, 666, 199, 199, 318, 8671, 63, 30737, 70, 305, 63, 1162, 8, 602, 304, 339, 1434, 63, 5250, 275, 1434, 14, 1294, 21950, 272, 1788, 275, 2519, 8, 1751, 12, 283, 39, 1484, 38, 1179, 63, 6389, 63, 9472, 358, 11, 602, 63, 5250, 59, 16, 2807, 602, 63, 5250, 59, 17, 2807, 602, 63, 5250, 59, 18, 2807, 2, 383, 14, 7966, 2, 272, 327, 870, 598, 320, 70, 305, 25323, 972, 14, 1462, 14, 7410, 360, 4616, 350, 323, 1959, 602, 339, 12698, 275, 20284, 8, 1501, 12, 283, 82, 297, 9701, 534, 7278, 18967, 20, 358, 339, 327, 664, 8983, 2860, 272, 634, 1956, 275, 12698, 14, 3669, 459, 4452, 418, 5873, 272, 634, 4654, 275, 12698, 14, 3669, 459, 5298, 418, 5873, 339, 25717, 18, 83, 29, 12698, 14, 3669, 459, 4308, 18, 418, 5873, 272, 25717, 21, 83, 29, 12698, 14, 3669, 459, 4308, 21, 418, 5873, 272, 25717, 1165, 83, 29, 12698, 14, 3669, 459, 4308, 1165, 418, 5873, 272, 5431, 275, 12698, 14, 3669, 459, 521, 418, 5873, 272, 9455, 8834, 275, 12698, 14, 3669, 459, 15628, 418, 5873, 339, 327, 3957, 1434, 12, 4212, 370, 3877, 1434, 1454, 6202, 13437, 900, 31, 272, 327, 870, 298, 7619, 1337, 577, 2335, 2, 272, 6204, 275, 12698, 14, 3669, 459, 521, 2278, 5260, 272, 10831, 275, 1967, 18, 602, 334, 4508, 23315, 6204, 29, 5260, 12, 11234, 534, 12664, 63, 2977, 358, 339, 366, 275, 980, 14, 1144, 8, 7966, 14, 3669, 459, 2297, 1105, 272, 327, 1406, 275, 788, 44, 31429, 3786, 297, 283, 9551, 7779, 297, 283, 4308, 18, 297, 283, 4308, 21, 297, 283, 4308, 1165, 297, 283, 4308, 18, 63, 2297, 63, 7045, 297, 283, 4308, 18, 63, 8595, 63, 2297, 63, 7045, 297, 283, 4308, 21, 63, 2297, 63, 7045, 297, 283, 4308, 21, 63, 8595, 63, 2297, 63, 7045, 297, 283, 4308, 1165, 63, 2297, 63, 7045, 297, 283, 4308, 1165, 63, 8595, 63, 2297, 63, 7045, 418, 272, 5431, 63, 1080, 9811, 272, 367, 284, 12, 74, 315, 3874, 8, 4508, 304, 267, 5431, 63, 1080, 14, 740, 8, 73, 9, 339, 11021, 63, 1080, 275, 378, 339, 24200, 275, 664, 497, 4778, 1451, 342, 339, 367, 8396, 12, 6132, 12, 25717, 18, 12, 25717, 21, 12, 25717, 1165, 315, 3482, 8, 76, 1956, 12, 634, 4654, 12, 25717, 18, 83, 12, 25717, 21, 83, 12, 25717, 1165, 83, 304, 1362, 198, 3, 870, 620, 8, 4452, 395, 620, 8, 5298, 9, 19066, 1362, 198, 893, 26, 19066, 198, 3, 870, 24200, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 19066, 198, 4308, 18, 63, 808, 275, 25717, 18, 10, 1609, 8, 264, 4778, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 18, 63, 4778, 1105, 19066, 198, 4308, 21, 63, 808, 275, 25717, 21, 10, 1609, 8, 264, 4778, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 21, 63, 4778, 1105, 19066, 198, 4308, 1165, 63, 808, 275, 25717, 1165, 10, 1609, 8, 264, 4778, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 1165, 63, 4778, 1105, 1362, 198, 2590, 26, 19066, 198, 4308, 18, 63, 808, 275, 25717, 18, 19066, 198, 4308, 21, 63, 808, 275, 25717, 21, 19066, 198, 4308, 1165, 63, 808, 275, 25717, 1165, 2728, 25717, 18, 275, 25717, 18, 63, 808, 267, 25717, 21, 275, 25717, 21, 63, 808, 267, 25717, 1165, 275, 25717, 1165, 63, 808, 398, 327, 870, 25717, 18, 12, 4308, 21, 12, 4308, 1165, 12, 24200, 59, 495, 8, 4452, 30372, 495, 8, 5298, 1874, 459, 4308, 18, 63, 4778, 418, 398, 666, 63, 262, 275, 942, 267, 666, 63, 262, 14, 740, 8, 4452, 9, 267, 666, 63, 262, 14, 740, 8, 5298, 9, 267, 666, 63, 262, 14, 740, 8, 4308, 18, 9, 267, 666, 63, 262, 14, 740, 8, 4308, 21, 9, 267, 666, 63, 262, 14, 740, 8, 4308, 1165, 9, 398, 25717, 18, 63, 2297, 63, 7045, 275, 942, 267, 25717, 21, 63, 2297, 63, 7045, 275, 942, 267, 25717, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zaccoz/odoo
addons/delivery/__openerp__.py
224
1905
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Delivery Costs', 'version': '1.0', 'category': 'Sales Management', 'description': """ Allows you to add delivery methods in sale orders and picking. ============================================================== You can define your own carrier and delivery grids for prices. When creating invoices from picking, OpenERP is able to add and compute the shipping line. """, 'author': 'OpenERP SA', 'depends': ['sale_stock'], 'data': [ 'security/ir.model.access.csv', 'delivery_view.xml', 'partner_view.xml', 'delivery_data.xml', 'views/report_shipping.xml', ], 'demo': ['delivery_demo.xml'], 'test': ['test/delivery_cost.yml', 'test/stock_move_values_with_invoice_before_delivery.yml', ], 'installable': True, 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 24640, 24681, 83, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 18220, 8259, 297, 272, 283, 1802, 356, 408, 199, 19780, 1265, 370, 1050, 18719, 3102, 315, 13590, 15460, 436, 12433, 14, 199, 12813, 17224, 199, 199, 5556, 883, 5627, 2195, 5705, 9590, 10742, 436, 18719, 27591, 795, 367, 1979, 823, 14, 3979, 6425, 221, 199, 28809, 687, 12433, 12, 7653, 365, 7688, 370, 1050, 436, 4526, 314, 27490, 1004, 14, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 8515, 63, 6088, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 14564, 63, 1345, 14, 1652, 297, 267, 283, 3899, 63, 1345, 14, 1652, 297, 267, 283, 14564, 63, 576, 14, 1652, 297, 267, 283, 4196, 15, 3070, 63, 17801, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 788, 14564, 63, 8768, 14, 1652, 995, 272, 283, 396, 356, 788, 396, 15, 14564, 63, 6336, 14, 11714, 297, 1467, 283, 396, 15, 6088, 63, 1185, 63, 1459, 63, 1045, 63, 5404, 63, 5182, 63, 14564, 14, 11714, 297, 1467, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 24640, 24681, 83, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 18220, 8259, 297, 272, 283, 1802, 356, 408, 199, 19780, 1265, 370, 1050, 18719, 3102, 315, 13590, 15460, 436, 12433, 14, 199, 12813, 17224, 199, 199, 5556, 883, 5627, 2195, 5705, 9590, 10742, 436, 18719, 27591, 795, 367, 1979, 823, 14, 3979, 6425, 221, 199, 28809, 687, 12433, 12, 7653, 365, 7688, 370, 1050, 436, 4526, 314, 27490, 1004, 14, 199, 7208, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 8912, 356, 788, 8515, 63, 6088, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 14564, 63, 1345, 14, 1652, 297, 267, 283, 3899, 63, 1345, 14, 1652, 297, 267, 283, 14564, 63, 576, 14, 1652, 297, 267, 283, 4196, 15, 3070, 63, 17801, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 788, 14564, 63, 8768, 14, 1652, 995, 272, 283, 396, 356, 788, 396, 15, 14564, 63, 6336, 14, 11714, 297, 1467, 283, 396, 15, 6088, 63, 1185, 63, 1459, 63, 1045, 63, 5404, 63, 5182, 63, 14564, 14, 11714, 297, 1467, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
deavid/bjsonrpc
bjsonrpc/main.py
1
2824
""" bjson/main.py Copyright (c) 2010 David Martinez Marti All rights reserved. Licensed under 3-clause BSD License. See LICENSE.txt for the full license text. """ import socket import bjsonrpc.server import bjsonrpc.connection import bjsonrpc.handlers __all__ = [ "createserver", "connect", ] def createserver(host="127.0.0.1", port=10123, handler_factory=bjsonrpc.handlers.NullHandler, sock=None, http=False): """ Creates a *bjson.server.Server* object linked to a listening socket. Parameters: **host** Address (IP or Host Name) to listen to as in *socket.bind*. Use "0.0.0.0" to listen to all address. By default this points to 127.0.0.1 to avoid security flaws. **port** Port number to bind the socket. In Unix, port numbers less than 1024 requires special permissions. **handler_factory** Class to instantiate to publish remote functions. **(return value)** A *bjson.server.Server* instance or raises an exception. Servers are usually created this way:: import bjsonrpc server = bjsonrpc.createserver("0.0.0.0") server.serve() Check :ref:`bjsonrpc.server` documentation """ if sock is None: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((host, port)) sock.listen(3) return bjsonrpc.server.Server(sock, handler_factory=handler_factory, http=http) def connect(host="127.0.0.1", port=10123, sock=None, handler_factory=bjsonrpc.handlers.NullHandler): """ Creates a *bjson.connection.Connection* object linked to a connected socket. Parameters: **host** Address (IP or Host Name) to connect to. **port** Port number to connect to. **handler_factory** Class to instantiate to publish remote functions to the server. By default this is *NullHandler* which means that no functions are executable by the server. **(return value)** A *bjson.connection.Connection* instance or raises an exception. Connections are usually created this way:: import bjsonrpc conn = bjsonrpc.connect("rpc.host.net") print conn.call.some_method_in_server_side() """ if sock is None: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) return bjsonrpc.connection.Connection(sock, handler_factory=handler_factory)
bsd-3-clause
[ 624, 272, 330, 1001, 15, 973, 14, 647, 2286, 1898, 334, 67, 9, 7129, 20232, 603, 580, 1132, 90, 16794, 280, 272, 2900, 4481, 4644, 14, 339, 3909, 1334, 650, 13, 8501, 6289, 844, 14, 5591, 1666, 5113, 14, 2424, 367, 314, 2615, 4190, 1318, 14, 199, 199, 624, 199, 199, 646, 2838, 199, 199, 646, 330, 31395, 14, 1000, 199, 646, 330, 31395, 14, 2105, 199, 646, 330, 31395, 14, 5586, 199, 199, 363, 452, 363, 275, 359, 272, 298, 981, 1000, 401, 272, 298, 2242, 401, 199, 61, 199, 199, 318, 1218, 1000, 8, 1102, 628, 4195, 14, 16, 14, 16, 14, 17, 401, 1844, 29, 4893, 1789, 12, 5591, 3016, 63, 3702, 29, 468, 834, 4354, 14, 5586, 14, 8849, 2461, 12, 272, 6771, 29, 403, 12, 1455, 29, 797, 304, 272, 408, 267, 10560, 282, 627, 468, 834, 14, 1000, 14, 3120, 10, 909, 10632, 370, 282, 22721, 2838, 14, 2728, 3897, 26, 2728, 1011, 1102, 538, 881, 9906, 334, 1772, 503, 10891, 2812, 9, 370, 6938, 370, 465, 315, 627, 3450, 14, 3409, 4856, 881, 3645, 298, 16, 14, 16, 14, 16, 14, 16, 2, 370, 6938, 370, 1006, 2287, 14, 4885, 849, 642, 4501, 370, 23664, 12792, 14, 16, 14, 16, 14, 17, 370, 5126, 6391, 17566, 3569, 14, 1779, 267, 1011, 719, 538, 881, 10977, 1329, 370, 5398, 314, 2838, 14, 1010, 13074, 12, 1844, 5579, 6656, 881, 2419, 6619, 5074, 4539, 3443, 14, 221, 1779, 267, 1011, 2232, 63, 3702, 538, 881, 8089, 370, 17321, 370, 2780, 3982, 3423, 14, 2728, 1011, 8, 1107, 574, 6422, 881, 437, 627, 468, 834, 14, 1000, 14, 3120, 10, 1256, 503, 6534, 376, 1919, 14, 2728, 7146, 83, 787, 9987, 2737, 642, 4340, 447, 27180, 492, 330, 31395, 7846, 1654, 275, 330, 31395, 14, 981, 1000, 480, 16, 14, 16, 14, 16, 14, 16, 531, 288, 1654, 14, 4909, 342, 10631, 2670, 520, 1121, 1705, 468, 834, 4354, 14, 1000, 64, 3794, 272, 408, 272, 340, 6771, 365, 488, 26, 267, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 272, 6771, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 907, 4701, 7803, 12, 413, 9, 272, 6771, 14, 3409, 1332, 1102, 12, 1844, 430, 272, 6771, 14, 5859, 8, 19, 9, 5591, 372, 330, 31395, 14, 1000, 14, 3120, 8, 5096, 12, 3016, 63, 3702, 29, 2232, 63, 3702, 12, 1455, 29, 1014, 9, 199, 199, 318, 4907, 8, 1102, 628, 4195, 14, 16, 14, 16, 14, 17, 401, 1844, 29, 4893, 1789, 12, 5591, 6771, 29, 403, 12, 3016, 63, 3702, 29, 468, 834, 4354, 14, 5586, 14, 8849, 2461, 304, 272, 408, 267, 10560, 282, 627, 468, 834, 14, 2105, 14, 3225, 10, 909, 10632, 370, 282, 8539, 267, 2838, 14, 2728, 3897, 26, 2728, 1011, 1102, 538, 881, 9906, 334, 1772, 503, 10891, 2812, 9, 370, 4907, 370, 14, 1779, 267, 1011, 719, 538, 881, 10977, 1329, 370, 4907, 370, 14, 1779, 267, 1011, 2232, 63, 3702, 538, 881, 8089, 370, 17321, 370, 2780, 3982, 3423, 370, 314, 1654, 14, 23664, 4885, 849, 642, 365, 627, 8849, 2461, 10, 1314, 4910, 626, 949, 3423, 787, 881, 7286, 701, 314, 1654, 14, 2728, 1011, 8, 1107, 574, 6422, 881, 437, 627, 468, 834, 14, 2105, 14, 3225, 10, 1256, 503, 6534, 376, 1919, 14, 2728, 8113, 83, 787, 9987, 2737, 642, 4340, 447, 27180, 492, 330, 31395, 7846, 2557, 275, 330, 31395, 14, 2242, 480, 4354, 14, 1102, 14, 846, 531, 288, 870, 2557, 14, 1250, 14, 3972, 63, 765, 63, 262, 63, 1000, 63, 2441, 342, 272, 408, 272, 340, 6771, 365, 488, 26, 267, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 272, 6771, 14, 2242, 1332, 1102, 12, 1844, 430, 272, 372, 330, 31395, 14, 2105, 14, 3225, 8, 5096, 12, 3016, 63, 3702, 29, 2232, 63, 3702, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 272, 330, 1001, 15, 973, 14, 647, 2286, 1898, 334, 67, 9, 7129, 20232, 603, 580, 1132, 90, 16794, 280, 272, 2900, 4481, 4644, 14, 339, 3909, 1334, 650, 13, 8501, 6289, 844, 14, 5591, 1666, 5113, 14, 2424, 367, 314, 2615, 4190, 1318, 14, 199, 199, 624, 199, 199, 646, 2838, 199, 199, 646, 330, 31395, 14, 1000, 199, 646, 330, 31395, 14, 2105, 199, 646, 330, 31395, 14, 5586, 199, 199, 363, 452, 363, 275, 359, 272, 298, 981, 1000, 401, 272, 298, 2242, 401, 199, 61, 199, 199, 318, 1218, 1000, 8, 1102, 628, 4195, 14, 16, 14, 16, 14, 17, 401, 1844, 29, 4893, 1789, 12, 5591, 3016, 63, 3702, 29, 468, 834, 4354, 14, 5586, 14, 8849, 2461, 12, 272, 6771, 29, 403, 12, 1455, 29, 797, 304, 272, 408, 267, 10560, 282, 627, 468, 834, 14, 1000, 14, 3120, 10, 909, 10632, 370, 282, 22721, 2838, 14, 2728, 3897, 26, 2728, 1011, 1102, 538, 881, 9906, 334, 1772, 503, 10891, 2812, 9, 370, 6938, 370, 465, 315, 627, 3450, 14, 3409, 4856, 881, 3645, 298, 16, 14, 16, 14, 16, 14, 16, 2, 370, 6938, 370, 1006, 2287, 14, 4885, 849, 642, 4501, 370, 23664, 12792, 14, 16, 14, 16, 14, 17, 370, 5126, 6391, 17566, 3569, 14, 1779, 267, 1011, 719, 538, 881, 10977, 1329, 370, 5398, 314, 2838, 14, 1010, 13074, 12, 1844, 5579, 6656, 881, 2419, 6619, 5074, 4539, 3443, 14, 221, 1779, 267, 1011, 2232, 63, 3702, 538, 881, 8089, 370, 17321, 370, 2780, 3982, 3423, 14, 2728, 1011, 8, 1107, 574, 6422, 881, 437, 627, 468, 834, 14, 1000, 14, 3120, 10, 1256, 503, 6534, 376, 1919, 14, 2728, 7146, 83, 787, 9987, 2737, 642, 4340, 447, 27180, 492, 330, 31395, 7846, 1654, 275, 330, 31395, 14, 981, 1000, 480, 16, 14, 16, 14, 16, 14, 16, 531, 288, 1654, 14, 4909, 342, 10631, 2670, 520, 1121, 1705, 468, 834, 4354, 14, 1000, 64, 3794, 272, 408, 272, 340, 6771, 365, 488, 26, 267, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 272, 6771, 14, 27689, 8, 3450, 14, 15096, 63, 17462, 12, 2838, 14, 4118, 63, 907, 4701, 7803, 12, 413, 9, 272, 6771, 14, 3409, 1332, 1102, 12, 1844, 430, 272, 6771, 14, 5859, 8, 19, 9, 5591, 372, 330, 31395, 14, 1000, 14, 3120, 8, 5096, 12, 3016, 63, 3702, 29, 2232, 63, 3702, 12, 1455, 29, 1014, 9, 199, 199, 318, 4907, 8, 1102, 628, 4195, 14, 16, 14, 16, 14, 17, 401, 1844, 29, 4893, 1789, 12, 5591, 6771, 29, 403, 12, 3016, 63, 3702, 29, 468, 834, 4354, 14, 5586, 14, 8849, 2461, 304, 272, 408, 267, 10560, 282, 627, 468, 834, 14, 2105, 14, 3225, 10, 909, 10632, 370, 282, 8539, 267, 2838, 14, 2728, 3897, 26, 2728, 1011, 1102, 538, 881, 9906, 334, 1772, 503, 10891, 2812, 9, 370, 4907, 370, 14, 1779, 267, 1011, 719, 538, 881, 10977, 1329, 370, 4907, 370, 14, 1779, 267, 1011, 2232, 63, 3702, 538, 881, 8089, 370, 17321, 370, 2780, 3982, 3423, 370, 314, 1654, 14, 23664, 4885, 849, 642, 365, 627, 8849, 2461, 10, 1314, 4910, 626, 949, 3423, 787, 881, 7286, 701, 314, 1654, 14, 2728, 1011, 8, 1107, 574, 6422, 881, 437, 627, 468, 834, 14, 2105, 14, 3225, 10, 1256, 503, 6534, 376, 1919, 14, 2728, 8113, 83, 787, 9987, 2737, 642, 4340, 447, 27180, 492, 330, 31395, 7846, 2557, 275, 330, 31395, 14, 2242, 480, 4354, 14, 1102, 14, 846, 531, 288, 870, 2557, 14, 1250, 14, 3972, 63, 765, 63, 262, 63, 1000, 63, 2441, 342, 272, 408, 272, 340, 6771, 365, 488, 26, 267, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 272, 6771, 14, 2242, 1332, 1102, 12, 1844, 430, 272, 372, 330, 31395, 14, 2105, 14, 3225, 8, 5096, 12, 3016, 63, 3702, 29, 2232, 63, 3702, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
testalt/electrum-dvc
gui/text.py
1
17436
import curses, datetime, locale from decimal import Decimal _ = lambda x:x #from i18n import _ from electrum_dvc.util import format_satoshis, set_verbosity from electrum_dvc.bitcoin import is_valid from electrum_dvc import Wallet, WalletStorage import tty, sys class ElectrumGui: def __init__(self, config, network): self.config = config self.network = network storage = WalletStorage(config) if not storage.file_exists: print "Wallet not found. try 'electrum-dvc create'" exit() self.wallet = Wallet(storage) self.wallet.start_threads(self.network) locale.setlocale(locale.LC_ALL, '') self.encoding = locale.getpreferredencoding() self.stdscr = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN) self.stdscr.keypad(1) self.stdscr.border(0) self.maxy, self.maxx = self.stdscr.getmaxyx() self.set_cursor(0) self.w = curses.newwin(10, 50, 5, 5) set_verbosity(False) self.tab = 0 self.pos = 0 self.popup_pos = 0 self.str_recipient = "" self.str_description = "" self.str_amount = "" self.str_fee = "" self.history = None if self.network: self.network.register_callback('updated', self.update) self.network.register_callback('connected', self.refresh) self.network.register_callback('disconnected', self.refresh) self.network.register_callback('disconnecting', self.refresh) self.tab_names = [_("History"), _("Send"), _("Receive"), _("Contacts"), _("Wall")] self.num_tabs = len(self.tab_names) def set_cursor(self, x): try: curses.curs_set(x) except Exception: pass def restore_or_create(self): pass def verify_seed(self): pass def get_string(self, y, x): self.set_cursor(1) curses.echo() self.stdscr.addstr( y, x, " "*20, curses.A_REVERSE) s = self.stdscr.getstr(y,x) curses.noecho() self.set_cursor(0) return s def update(self): self.update_history() if self.tab == 0: self.print_history() self.refresh() def print_history(self): width = [20, 40, 14, 14] delta = (self.maxx - sum(width) - 4)/3 format_str = "%"+"%d"%width[0]+"s"+"%"+"%d"%(width[1]+delta)+"s"+"%"+"%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s" if self.history is None: self.update_history() self.print_list(self.history[::-1], format_str%( _("Date"), _("Description"), _("Amount"), _("Balance"))) def update_history(self): width = [20, 40, 14, 14] delta = (self.maxx - sum(width) - 4)/3 format_str = "%"+"%d"%width[0]+"s"+"%"+"%d"%(width[1]+delta)+"s"+"%"+"%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s" b = 0 self.history = [] for item in self.wallet.get_tx_history(): tx_hash, conf, is_mine, value, fee, balance, timestamp = item if conf: try: time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3] except Exception: time_str = "------" else: time_str = 'pending' label, is_default_label = self.wallet.get_label(tx_hash) self.history.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) ) def print_balance(self): if not self.network: msg = _("Offline") elif self.network.is_connected(): if not self.wallet.up_to_date: msg = _("Synchronizing...") else: c, u = self.wallet.get_balance() msg = _("Balance")+": %f "%(Decimal( c ) / 100000000) if u: msg += " [%f unconfirmed]"%(Decimal( u ) / 100000000) else: msg = _("Not connected") self.stdscr.addstr( self.maxy -1, 3, msg) for i in range(self.num_tabs): self.stdscr.addstr( 0, 2 + 2*i + len(''.join(self.tab_names[0:i])), ' '+self.tab_names[i]+' ', curses.A_BOLD if self.tab == i else 0) self.stdscr.addstr( self.maxy -1, self.maxx-30, ' '.join([_("Settings"), _("Network"), _("Quit")])) def print_contacts(self): messages = map(lambda addr: "%30s %30s "%(addr, self.wallet.labels.get(addr,"")), self.wallet.addressbook) self.print_list(messages, "%19s %25s "%("Address", "Label")) def print_receive(self): fmt = "%-35s %-30s" messages = map(lambda addr: fmt % (addr, self.wallet.labels.get(addr,"")), self.wallet.addresses()) self.print_list(messages, fmt % ("Address", "Label")) def print_edit_line(self, y, label, text, index, size): text += " "*(size - len(text) ) self.stdscr.addstr( y, 2, label) self.stdscr.addstr( y, 15, text, curses.A_REVERSE if self.pos%6==index else curses.color_pair(1)) def print_send_tab(self): self.stdscr.clear() self.print_edit_line(3, _("Pay to"), self.str_recipient, 0, 40) self.print_edit_line(5, _("Description"), self.str_description, 1, 40) self.print_edit_line(7, _("Amount"), self.str_amount, 2, 15) self.print_edit_line(9, _("Fee"), self.str_fee, 3, 15) self.stdscr.addstr( 12, 15, _("[Send]"), curses.A_REVERSE if self.pos%6==4 else curses.color_pair(2)) self.stdscr.addstr( 12, 25, _("[Clear]"), curses.A_REVERSE if self.pos%6==5 else curses.color_pair(2)) def print_banner(self): if self.network: self.print_list( self.network.banner.split('\n')) def print_list(self, list, firstline = None): self.maxpos = len(list) if not self.maxpos: return if firstline: firstline += " "*(self.maxx -2 - len(firstline)) self.stdscr.addstr( 1, 1, firstline ) for i in range(self.maxy-4): msg = list[i] if i < len(list) else "" msg += " "*(self.maxx - 2 - len(msg)) m = msg[0:self.maxx - 2] m = m.encode(self.encoding) self.stdscr.addstr( i+2, 1, m, curses.A_REVERSE if i == (self.pos % self.maxpos) else 0) def refresh(self): if self.tab == -1: return self.stdscr.border(0) self.print_balance() self.stdscr.refresh() def main_command(self): c = self.stdscr.getch() print c if c == curses.KEY_RIGHT: self.tab = (self.tab + 1)%self.num_tabs elif c == curses.KEY_LEFT: self.tab = (self.tab - 1)%self.num_tabs elif c == curses.KEY_DOWN: self.pos +=1 elif c == curses.KEY_UP: self.pos -= 1 elif c == 9: self.pos +=1 # tab elif curses.unctrl(c) in ['^W', '^C', '^X', '^Q']: self.tab = -1 elif curses.unctrl(c) in ['^N']: self.network_dialog() elif curses.unctrl(c) == '^S': self.settings_dialog() else: return c if self.pos<0: self.pos=0 if self.pos>=self.maxpos: self.pos=self.maxpos - 1 def run_tab(self, i, print_func, exec_func): while self.tab == i: self.stdscr.clear() print_func() self.refresh() c = self.main_command() if c: exec_func(c) def run_history_tab(self, c): if c == 10: out = self.run_popup('',["blah","foo"]) def edit_str(self, target, c, is_num=False): # detect backspace if c in [8, 127, 263] and target: target = target[:-1] elif not is_num or curses.unctrl(c) in '0123456789.': target += curses.unctrl(c) return target def run_send_tab(self, c): if self.pos%6 == 0: self.str_recipient = self.edit_str(self.str_recipient, c) if self.pos%6 == 1: self.str_description = self.edit_str(self.str_description, c) if self.pos%6 == 2: self.str_amount = self.edit_str(self.str_amount, c, True) elif self.pos%6 == 3: self.str_fee = self.edit_str(self.str_fee, c, True) elif self.pos%6==4: if c == 10: self.do_send() elif self.pos%6==5: if c == 10: self.do_clear() def run_receive_tab(self, c): if c == 10: out = self.run_popup('Address', ["Edit label", "Freeze", "Prioritize"]) def run_contacts_tab(self, c): if c == 10 and self.wallet.addressbook: out = self.run_popup('Adress', ["Copy", "Pay to", "Edit label", "Delete"]).get('button') address = self.wallet.addressbook[self.pos%len(self.wallet.addressbook)] if out == "Pay to": self.tab = 1 self.str_recipient = address self.pos = 2 elif out == "Edit label": s = self.get_string(6 + self.pos, 18) if s: self.wallet.labels[address] = s def run_banner_tab(self, c): self.show_message(repr(c)) pass def main(self,url): tty.setraw(sys.stdin) while self.tab != -1: self.run_tab(0, self.print_history, self.run_history_tab) self.run_tab(1, self.print_send_tab, self.run_send_tab) self.run_tab(2, self.print_receive, self.run_receive_tab) self.run_tab(3, self.print_contacts, self.run_contacts_tab) self.run_tab(4, self.print_banner, self.run_banner_tab) tty.setcbreak(sys.stdin) curses.nocbreak() self.stdscr.keypad(0) curses.echo() curses.endwin() def do_clear(self): self.str_amount = '' self.str_recipient = '' self.str_fee = '' self.str_description = '' def do_send(self): if not is_valid(self.str_recipient): self.show_message(_('Invalid devcoin address')) return try: amount = int( Decimal( self.str_amount) * 100000000 ) except Exception: self.show_message(_('Invalid Amount')) return try: fee = int( Decimal( self.str_fee) * 100000000 ) except Exception: self.show_message(_('Invalid Fee')) return if self.wallet.use_encryption: password = self.password_dialog() if not password: return else: password = None try: tx = self.wallet.mktx( [(self.str_recipient, amount)], password, fee) except Exception as e: self.show_message(str(e)) return if self.str_description: self.wallet.labels[tx.hash()] = self.str_description h = self.wallet.send_tx(tx) self.show_message(_("Please wait..."), getchar=False) self.wallet.tx_event.wait() status, msg = self.wallet.receive_tx( h, tx ) if status: self.show_message(_('Payment sent.')) self.do_clear() #self.update_contacts_tab() else: self.show_message(_('Error')) def show_message(self, message, getchar = True): w = self.w w.clear() w.border(0) for i, line in enumerate(message.split('\n')): w.addstr(2+i,2,line) w.refresh() if getchar: c = self.stdscr.getch() def run_popup(self, title, items): return self.run_dialog(title, map(lambda x: {'type':'button','label':x}, items), interval=1, y_pos = self.pos+3) def network_dialog(self): if not self.network: return auto_connect = self.network.config.get('auto_cycle') host, port, protocol = self.network.default_server.split(':') srv = 'auto-connect' if auto_connect else self.network.default_server out = self.run_dialog('Network', [ {'label':'server', 'type':'str', 'value':srv}, {'label':'proxy', 'type':'str', 'value':self.config.get('proxy', '')}, ], buttons = 1) if out: if out.get('server'): server = out.get('server') auto_connect = server == 'auto-connect' if not auto_connect: try: host, port, protocol = server.split(':') except Exception: self.show_message("Error:" + server + "\nIn doubt, type \"auto-connect\"") return False if out.get('proxy'): proxy = self.parse_proxy_options(out.get('proxy')) else: proxy = None self.network.set_parameters(host, port, protocol, proxy, auto_connect) def settings_dialog(self): out = self.run_dialog('Settings', [ {'label':'Default GUI', 'type':'list', 'choices':['classic','lite','gtk','text'], 'value':self.config.get('gui')}, {'label':'Default fee', 'type':'satoshis', 'value': format_satoshis(self.wallet.fee).strip() } ], buttons = 1) if out: if out.get('Default GUI'): self.config.set_key('gui', out['Default GUI'], True) if out.get('Default fee'): fee = int ( Decimal( out['Default fee']) *10000000 ) self.config.set_key('fee_per_kb', fee, True) def password_dialog(self): out = self.run_dialog('Password', [ {'label':'Password', 'type':'password', 'value':''} ], buttons = 1) return out.get('Password') def run_dialog(self, title, items, interval=2, buttons=None, y_pos=3): self.popup_pos = 0 self.w = curses.newwin( 5 + len(items)*interval + (2 if buttons else 0), 50, y_pos, 5) w = self.w out = {} while True: w.clear() w.border(0) w.addstr( 0, 2, title) num = len(items) numpos = num if buttons: numpos += 2 for i in range(num): item = items[i] label = item.get('label') if item.get('type') == 'list': value = item.get('value','') elif item.get('type') == 'satoshis': value = item.get('value','') elif item.get('type') == 'str': value = item.get('value','') elif item.get('type') == 'password': value = '*'*len(item.get('value','')) else: value = '' if len(value)<20: value += ' '*(20-len(value)) if item.has_key('value'): w.addstr( 2+interval*i, 2, label) w.addstr( 2+interval*i, 15, value, curses.A_REVERSE if self.popup_pos%numpos==i else curses.color_pair(1) ) else: w.addstr( 2+interval*i, 2, label, curses.A_REVERSE if self.popup_pos%numpos==i else 0) if buttons: w.addstr( 5+interval*i, 10, "[ ok ]", curses.A_REVERSE if self.popup_pos%numpos==(numpos-2) else curses.color_pair(2)) w.addstr( 5+interval*i, 25, "[cancel]", curses.A_REVERSE if self.popup_pos%numpos==(numpos-1) else curses.color_pair(2)) w.refresh() c = self.stdscr.getch() if c in [ord('q'), 27]: break elif c in [curses.KEY_LEFT, curses.KEY_UP]: self.popup_pos -= 1 elif c in [curses.KEY_RIGHT, curses.KEY_DOWN]: self.popup_pos +=1 else: i = self.popup_pos%numpos if buttons and c==10: if i == numpos-2: return out elif i == numpos -1: return {} item = items[i] _type = item.get('type') if _type == 'str': item['value'] = self.edit_str(item['value'], c) out[item.get('label')] = item.get('value') elif _type == 'password': item['value'] = self.edit_str(item['value'], c) out[item.get('label')] = item ['value'] elif _type == 'satoshis': item['value'] = self.edit_str(item['value'], c, True) out[item.get('label')] = item.get('value') elif _type == 'list': choices = item.get('choices') try: j = choices.index(item.get('value')) except Exception: j = 0 new_choice = choices[(j + 1)% len(choices)] item['value'] = new_choice out[item.get('label')] = item.get('value') elif _type == 'button': out['button'] = item.get('label') break return out
gpl-3.0
[ 646, 15429, 12, 2197, 12, 5867, 199, 504, 6107, 492, 6345, 199, 63, 275, 2400, 671, 26, 88, 199, 3, 504, 284, 1085, 78, 492, 485, 199, 504, 28933, 28430, 63, 68, 6737, 14, 1974, 492, 1475, 63, 83, 11318, 609, 374, 12, 663, 63, 9833, 199, 504, 28933, 28430, 63, 68, 6737, 14, 22816, 492, 365, 63, 1078, 199, 199, 504, 28933, 28430, 63, 68, 6737, 492, 644, 9478, 12, 644, 9478, 6408, 199, 199, 646, 21862, 12, 984, 421, 199, 533, 662, 1264, 28430, 4324, 26, 339, 347, 636, 826, 721, 277, 12, 1101, 12, 2784, 304, 398, 291, 14, 888, 275, 1101, 267, 291, 14, 1200, 275, 2784, 267, 4887, 275, 644, 9478, 6408, 8, 888, 9, 267, 340, 440, 4887, 14, 493, 63, 2444, 26, 288, 870, 298, 55, 9478, 440, 1911, 14, 862, 283, 26334, 28430, 13, 68, 6737, 1218, 4065, 288, 4458, 342, 398, 291, 14, 13892, 275, 644, 9478, 8, 3494, 9, 267, 291, 14, 13892, 14, 928, 63, 6962, 8, 277, 14, 1200, 9, 398, 5867, 14, 409, 5508, 8, 5508, 14, 7027, 63, 1761, 12, 4074, 267, 291, 14, 2991, 275, 5867, 14, 362, 24283, 264, 848, 1523, 342, 398, 291, 14, 1516, 11047, 275, 15429, 14, 826, 11047, 342, 267, 15429, 14, 889, 7878, 342, 267, 15429, 14, 2894, 1693, 342, 267, 15429, 14, 928, 63, 2326, 342, 267, 15429, 14, 1180, 63, 885, 63, 7120, 342, 267, 15429, 14, 826, 63, 3852, 8, 17, 12, 15429, 14, 7134, 63, 18817, 12, 15429, 14, 7134, 63, 23536, 9, 267, 15429, 14, 826, 63, 3852, 8, 18, 12, 15429, 14, 7134, 63, 18817, 12, 15429, 14, 7134, 63, 15068, 879, 9, 267, 291, 14, 1516, 11047, 14, 498, 6226, 8, 17, 9, 267, 291, 14, 1516, 11047, 14, 8665, 8, 16, 9, 267, 291, 14, 988, 89, 12, 291, 14, 988, 88, 275, 291, 14, 1516, 11047, 14, 362, 988, 20937, 342, 267, 291, 14, 409, 63, 3937, 8, 16, 9, 267, 291, 14, 87, 275, 15429, 14, 1222, 2676, 8, 709, 12, 5238, 12, 959, 12, 959, 9, 398, 663, 63, 9833, 8, 797, 9, 267, 291, 14, 2902, 275, 378, 267, 291, 14, 1712, 275, 378, 267, 291, 14, 16020, 63, 1712, 275, 378, 398, 291, 14, 495, 63, 10043, 275, 3087, 267, 291, 14, 495, 63, 1802, 275, 3087, 267, 291, 14, 495, 63, 4606, 275, 3087, 267, 291, 14, 495, 63, 11195, 275, 3087, 267, 291, 14, 5570, 275, 488, 267, 267, 340, 291, 14, 1200, 26, 7205, 291, 14, 1200, 14, 2683, 63, 3058, 360, 5334, 297, 291, 14, 873, 9, 288, 291, 14, 1200, 14, 2683, 63, 3058, 360, 7113, 297, 291, 14, 6635, 9, 288, 291, 14, 1200, 14, 2683, 63, 3058, 360, 27476, 297, 291, 14, 6635, 9, 288, 291, 14, 1200, 14, 2683, 63, 3058, 360, 10673, 316, 297, 291, 14, 6635, 9, 398, 291, 14, 2902, 63, 1247, 275, 359, 14332, 12114, 1288, 3824, 6795, 1288, 3824, 14235, 1288, 3824, 714, 11961, 1288, 3824, 18018, 11323, 267, 291, 14, 1507, 63, 8741, 275, 822, 8, 277, 14, 2902, 63, 1247, 9, 2378, 347, 663, 63, 3937, 8, 277, 12, 671, 304, 267, 862, 26, 288, 15429, 14, 17255, 63, 409, 8, 88, 9, 267, 871, 2186, 26, 288, 986, 339, 347, 9066, 63, 269, 63, 981, 8, 277, 304, 267, 986, 339, 347, 4911, 63, 5176, 8, 277, 304, 267, 986, 2286, 347, 664, 63, 875, 8, 277, 12, 612, 12, 671, 304, 267, 291, 14, 409, 63, 3937, 8, 17, 9, 267, 15429, 14, 7878, 342, 267, 291, 14, 1516, 11047, 14, 525, 495, 8, 612, 12, 671, 12, 298, 8969, 1165, 12, 15429, 14, 33, 63, 907, 21233, 9, 267, 308, 275, 291, 14, 1516, 11047, 14, 362, 495, 8, 89, 12, 88, 9, 267, 15429, 14, 889, 7878, 342, 267, 291, 14, 409, 63, 3937, 8, 16, 9, 267, 372, 308, 339, 347, 1678, 8, 277, 304, 267, 291, 14, 873, 63, 5570, 342, 267, 340, 291, 14, 2902, 508, 378, 26, 7205, 291, 14, 1361, 63, 5570, 342, 267, 291, 14, 6635, 342, 339, 347, 870, 63, 5570, 8, 277, 304, 398, 3462, 275, 359, 1165, 12, 6335, 12, 4329, 12, 4329, 61, 267, 5762, 275, 334, 277, 14, 988, 88, 446, 3089, 8, 2063, 9, 446, 841, 2447, 19, 267, 1475, 63, 495, 275, 2071, 2, 5207, 5, 68, 6808, 2063, 59, 16, 2807, 2, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 17, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 18, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 19, 2807, 3136, 18663, 83, 2, 398, 340, 291, 14, 5570, 365, 488, 26, 288, 291, 14, 873, 63, 5570, 342, 398, 291, 14, 1361, 63, 513, 8, 277, 14, 5570, 14172, 17, 467, 1475, 63, 495, 2840, 3824, 2506, 1288, 3824, 5831, 1288, 3824, 18785, 1288, 3824, 27106, 13324, 339, 347, 1678, 63, 5570, 8, 277, 304, 267, 3462, 275, 359, 1165, 12, 6335, 12, 4329, 12, 4329, 61, 267, 5762, 275, 334, 277, 14, 988, 88, 446, 3089, 8, 2063, 9, 446, 841, 2447, 19, 267, 1475, 63, 495, 275, 2071, 2, 5207, 5, 68, 6808, 2063, 59, 16, 2807, 2, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 17, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 18, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 19, 2807, 3136, 18663, 83, 2, 398, 330, 275, 378, 4960, 291, 14, 5570, 275, 942, 398, 367, 1242, 315, 291, 14, 13892, 14, 362, 63, 2347, 63, 5570, 837, 288, 4773, 63, 2227, 12, 3743, 12, 365, 63, 19153, 12, 574, 12, 14751, 12, 14094, 12, 4913, 275, 1242, 288, 340, 3743, 26, 355, 862, 26, 490, 900, 63, 495, 275, 2197, 14, 2083, 14, 18531, 8, 4913, 680, 17070, 360, 5320, 4439, 19, 61, 355, 871, 2186, 26, 490, 900, 63, 495, 275, 298, 8648, 2, 288, 587, 26, 355, 900, 63, 495, 275, 283, 6455, 7, 953 ]
[ 15429, 12, 2197, 12, 5867, 199, 504, 6107, 492, 6345, 199, 63, 275, 2400, 671, 26, 88, 199, 3, 504, 284, 1085, 78, 492, 485, 199, 504, 28933, 28430, 63, 68, 6737, 14, 1974, 492, 1475, 63, 83, 11318, 609, 374, 12, 663, 63, 9833, 199, 504, 28933, 28430, 63, 68, 6737, 14, 22816, 492, 365, 63, 1078, 199, 199, 504, 28933, 28430, 63, 68, 6737, 492, 644, 9478, 12, 644, 9478, 6408, 199, 199, 646, 21862, 12, 984, 421, 199, 533, 662, 1264, 28430, 4324, 26, 339, 347, 636, 826, 721, 277, 12, 1101, 12, 2784, 304, 398, 291, 14, 888, 275, 1101, 267, 291, 14, 1200, 275, 2784, 267, 4887, 275, 644, 9478, 6408, 8, 888, 9, 267, 340, 440, 4887, 14, 493, 63, 2444, 26, 288, 870, 298, 55, 9478, 440, 1911, 14, 862, 283, 26334, 28430, 13, 68, 6737, 1218, 4065, 288, 4458, 342, 398, 291, 14, 13892, 275, 644, 9478, 8, 3494, 9, 267, 291, 14, 13892, 14, 928, 63, 6962, 8, 277, 14, 1200, 9, 398, 5867, 14, 409, 5508, 8, 5508, 14, 7027, 63, 1761, 12, 4074, 267, 291, 14, 2991, 275, 5867, 14, 362, 24283, 264, 848, 1523, 342, 398, 291, 14, 1516, 11047, 275, 15429, 14, 826, 11047, 342, 267, 15429, 14, 889, 7878, 342, 267, 15429, 14, 2894, 1693, 342, 267, 15429, 14, 928, 63, 2326, 342, 267, 15429, 14, 1180, 63, 885, 63, 7120, 342, 267, 15429, 14, 826, 63, 3852, 8, 17, 12, 15429, 14, 7134, 63, 18817, 12, 15429, 14, 7134, 63, 23536, 9, 267, 15429, 14, 826, 63, 3852, 8, 18, 12, 15429, 14, 7134, 63, 18817, 12, 15429, 14, 7134, 63, 15068, 879, 9, 267, 291, 14, 1516, 11047, 14, 498, 6226, 8, 17, 9, 267, 291, 14, 1516, 11047, 14, 8665, 8, 16, 9, 267, 291, 14, 988, 89, 12, 291, 14, 988, 88, 275, 291, 14, 1516, 11047, 14, 362, 988, 20937, 342, 267, 291, 14, 409, 63, 3937, 8, 16, 9, 267, 291, 14, 87, 275, 15429, 14, 1222, 2676, 8, 709, 12, 5238, 12, 959, 12, 959, 9, 398, 663, 63, 9833, 8, 797, 9, 267, 291, 14, 2902, 275, 378, 267, 291, 14, 1712, 275, 378, 267, 291, 14, 16020, 63, 1712, 275, 378, 398, 291, 14, 495, 63, 10043, 275, 3087, 267, 291, 14, 495, 63, 1802, 275, 3087, 267, 291, 14, 495, 63, 4606, 275, 3087, 267, 291, 14, 495, 63, 11195, 275, 3087, 267, 291, 14, 5570, 275, 488, 267, 267, 340, 291, 14, 1200, 26, 7205, 291, 14, 1200, 14, 2683, 63, 3058, 360, 5334, 297, 291, 14, 873, 9, 288, 291, 14, 1200, 14, 2683, 63, 3058, 360, 7113, 297, 291, 14, 6635, 9, 288, 291, 14, 1200, 14, 2683, 63, 3058, 360, 27476, 297, 291, 14, 6635, 9, 288, 291, 14, 1200, 14, 2683, 63, 3058, 360, 10673, 316, 297, 291, 14, 6635, 9, 398, 291, 14, 2902, 63, 1247, 275, 359, 14332, 12114, 1288, 3824, 6795, 1288, 3824, 14235, 1288, 3824, 714, 11961, 1288, 3824, 18018, 11323, 267, 291, 14, 1507, 63, 8741, 275, 822, 8, 277, 14, 2902, 63, 1247, 9, 2378, 347, 663, 63, 3937, 8, 277, 12, 671, 304, 267, 862, 26, 288, 15429, 14, 17255, 63, 409, 8, 88, 9, 267, 871, 2186, 26, 288, 986, 339, 347, 9066, 63, 269, 63, 981, 8, 277, 304, 267, 986, 339, 347, 4911, 63, 5176, 8, 277, 304, 267, 986, 2286, 347, 664, 63, 875, 8, 277, 12, 612, 12, 671, 304, 267, 291, 14, 409, 63, 3937, 8, 17, 9, 267, 15429, 14, 7878, 342, 267, 291, 14, 1516, 11047, 14, 525, 495, 8, 612, 12, 671, 12, 298, 8969, 1165, 12, 15429, 14, 33, 63, 907, 21233, 9, 267, 308, 275, 291, 14, 1516, 11047, 14, 362, 495, 8, 89, 12, 88, 9, 267, 15429, 14, 889, 7878, 342, 267, 291, 14, 409, 63, 3937, 8, 16, 9, 267, 372, 308, 339, 347, 1678, 8, 277, 304, 267, 291, 14, 873, 63, 5570, 342, 267, 340, 291, 14, 2902, 508, 378, 26, 7205, 291, 14, 1361, 63, 5570, 342, 267, 291, 14, 6635, 342, 339, 347, 870, 63, 5570, 8, 277, 304, 398, 3462, 275, 359, 1165, 12, 6335, 12, 4329, 12, 4329, 61, 267, 5762, 275, 334, 277, 14, 988, 88, 446, 3089, 8, 2063, 9, 446, 841, 2447, 19, 267, 1475, 63, 495, 275, 2071, 2, 5207, 5, 68, 6808, 2063, 59, 16, 2807, 2, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 17, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 18, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 19, 2807, 3136, 18663, 83, 2, 398, 340, 291, 14, 5570, 365, 488, 26, 288, 291, 14, 873, 63, 5570, 342, 398, 291, 14, 1361, 63, 513, 8, 277, 14, 5570, 14172, 17, 467, 1475, 63, 495, 2840, 3824, 2506, 1288, 3824, 5831, 1288, 3824, 18785, 1288, 3824, 27106, 13324, 339, 347, 1678, 63, 5570, 8, 277, 304, 267, 3462, 275, 359, 1165, 12, 6335, 12, 4329, 12, 4329, 61, 267, 5762, 275, 334, 277, 14, 988, 88, 446, 3089, 8, 2063, 9, 446, 841, 2447, 19, 267, 1475, 63, 495, 275, 2071, 2, 5207, 5, 68, 6808, 2063, 59, 16, 2807, 2, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 17, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 18, 2807, 3136, 18663, 83, 2, 5207, 5, 2, 5207, 5, 68, 14007, 2063, 59, 19, 2807, 3136, 18663, 83, 2, 398, 330, 275, 378, 4960, 291, 14, 5570, 275, 942, 398, 367, 1242, 315, 291, 14, 13892, 14, 362, 63, 2347, 63, 5570, 837, 288, 4773, 63, 2227, 12, 3743, 12, 365, 63, 19153, 12, 574, 12, 14751, 12, 14094, 12, 4913, 275, 1242, 288, 340, 3743, 26, 355, 862, 26, 490, 900, 63, 495, 275, 2197, 14, 2083, 14, 18531, 8, 4913, 680, 17070, 360, 5320, 4439, 19, 61, 355, 871, 2186, 26, 490, 900, 63, 495, 275, 298, 8648, 2, 288, 587, 26, 355, 900, 63, 495, 275, 283, 6455, 7, 953, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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