text stringlengths 0 828 |
|---|
4375,"def uuid(self, type, val): |
""""""Return the item-uuid for a identifier"""""" |
picker = lambda x: x.get('uuid', x) |
return self._get((type, val), picker)" |
4376,"def search(self, q, field=None, page=None, per_page=None): |
""""""Search across all (without field) or in specific field |
(valid fields at http://www.loc.gov/standards/mods/mods-outline.html)"""""" |
def picker(results): |
if type(results['result']) == list: |
return results['result'] |
else: |
return [results['result']] |
return self._get(('search',), picker, q=q, field=field, page=page, per_page=per_page)" |
4377,"def mods(self, uuid): |
""""""Return a mods record for a given uuid"""""" |
picker = lambda x: x.get('mods', {}) |
return self._get(('mods', uuid), picker)" |
4378,"def _get(self, components, picker, **params): |
""""""Generic get which handles call to api and setting of results |
Return: Results object"""""" |
url = '/'.join((self.base,) + components) |
headers = {""Authorization"": ""Token token="" + self._token} |
params['page'] = params.get('page') or self.page |
params['per_page'] = params.get('per_page') or self.per_page |
r = requests.get(""."".join([url, self.format]), |
params=params, |
headers=headers) |
_next = self._nextify(components, picker, params) |
return Result(r, picker, _next)" |
4379,"def convert_datetext_to_dategui(datetext, ln=None, secs=False): |
""""""Convert: '2005-11-16 15:11:57' => '16 nov 2005, 15:11' |
Or optionally with seconds: |
'2005-11-16 15:11:57' => '16 nov 2005, 15:11:57' |
Month is internationalized |
"""""" |
assert ln is None, 'setting language is not supported' |
try: |
datestruct = convert_datetext_to_datestruct(datetext) |
if datestruct == datestruct_default: |
raise ValueError |
if secs: |
output_format = ""d MMM Y, H:mm:ss"" |
else: |
output_format = ""d MMM Y, H:mm"" |
dt = datetime.fromtimestamp(time.mktime(datestruct)) |
return babel_format_datetime(dt, output_format) |
except ValueError: |
return _(""N/A"")" |
4380,"def get_datetext(year, month, day): |
""""""year=2005, month=11, day=16 => '2005-11-16 00:00:00'"""""" |
input_format = ""%Y-%m-%d"" |
try: |
datestruct = time.strptime(""%i-%i-%i"" % (year, month, day), |
input_format) |
return strftime(datetext_format, datestruct) |
except: |
return datetext_default" |
4381,"def get_i18n_day_name(day_nb, display='short', ln=None): |
""""""Get the string representation of a weekday, internationalized |
@param day_nb: number of weekday UNIX like. |
=> 0=Sunday |
@param ln: language for output |
@return: the string representation of the day |
"""""" |
ln = default_ln(ln) |
_ = gettext_set_language(ln) |
if display == 'short': |
days = {0: _(""Sun""), |
1: _(""Mon""), |
2: _(""Tue""), |
3: _(""Wed""), |
4: _(""Thu""), |
5: _(""Fri""), |
6: _(""Sat"")} |
else: |
days = {0: _(""Sunday""), |
1: _(""Monday""), |
2: _(""Tuesday""), |
3: _(""Wednesday""), |
4: _(""Thursday""), |
5: _(""Friday""), |
6: _(""Saturday"")} |
return days[day_nb]" |
4382,"def get_i18n_month_name(month_nb, display='short', ln=None): |
""""""Get a non-numeric representation of a month, internationalized. |
@param month_nb: number of month, (1 based!) |
=>1=jan,..,12=dec |
@param ln: language for output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.