[074d3d]: / mne / io / nirx / _localized_abbr.py

Download this file

147 lines (142 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
"""Localizations for meas_date extraction."""
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
# This file was generated on 2021/01/31 on an Ubuntu system.
# When getting "unsupported locale setting" on Ubuntu (e.g., with localepurge),
# use "sudo locale-gen de_DE" etc. then "sudo update-locale".
"""
import datetime
import locale
print('_localized_abbr = {')
for loc in ('en_US.utf8', 'de_DE', 'fr_FR', 'it_IT'):
print(f' {repr(loc)}: {{')
print(' "month": {', end='')
month_abbr = set()
for month in range(1, 13): # Month as locale’s abbreviated name
locale.setlocale(locale.LC_TIME, "en_US.utf8")
dt = datetime.datetime(year=2000, month=month, day=1)
val = dt.strftime("%b").lower()
locale.setlocale(locale.LC_TIME, loc)
key = dt.strftime("%b").lower()
month_abbr.add(key)
print(f'{repr(key)}: {repr(val)}, ', end='')
print('}, # noqa')
print(' "weekday": {', end='')
weekday_abbr = set()
for day in range(1, 8): # Weekday as locale’s abbreviated name.
locale.setlocale(locale.LC_TIME, "en_US.utf8")
dt = datetime.datetime(year=2000, month=1, day=day)
val = dt.strftime("%a").lower()
locale.setlocale(locale.LC_TIME, loc)
key = dt.strftime("%a").lower()
assert key not in weekday_abbr, key
weekday_abbr.add(key)
print(f'{repr(key)}: {repr(val)}, ', end='')
print('}, # noqa')
print(' },')
print('}\n')
"""
# TODO: this should really be outsourced to a dedicated module like arrow or babel
_localized_abbr = {
"en_US.utf8": {
"month": {
"jan": "jan",
"feb": "feb",
"mar": "mar",
"apr": "apr",
"may": "may",
"jun": "jun",
"jul": "jul",
"aug": "aug",
"sep": "sep",
"oct": "oct",
"nov": "nov",
"dec": "dec",
}, # noqa
"weekday": {
"sat": "sat",
"sun": "sun",
"mon": "mon",
"tue": "tue",
"wed": "wed",
"thu": "thu",
"fri": "fri",
}, # noqa
},
"de_DE": {
"month": {
"jan": "jan",
"feb": "feb",
"mär": "mar",
"apr": "apr",
"mai": "may",
"jun": "jun",
"jul": "jul",
"aug": "aug",
"sep": "sep",
"okt": "oct",
"nov": "nov",
"dez": "dec",
}, # noqa
"weekday": {
"sa": "sat",
"so": "sun",
"mo": "mon",
"di": "tue",
"mi": "wed",
"do": "thu",
"fr": "fri",
}, # noqa
},
"fr_FR": {
"month": {
"janv.": "jan",
"févr.": "feb",
"mars": "mar",
"avril": "apr",
"mai": "may",
"juin": "jun",
"juil.": "jul",
"août": "aug",
"sept.": "sep",
"oct.": "oct",
"nov.": "nov",
"déc.": "dec",
}, # noqa
"weekday": {
"sam.": "sat",
"dim.": "sun",
"lun.": "mon",
"mar.": "tue",
"mer.": "wed",
"jeu.": "thu",
"ven.": "fri",
}, # noqa
},
"it_IT": {
"month": {
"gen": "jan",
"feb": "feb",
"mar": "mar",
"apr": "apr",
"mag": "may",
"giu": "jun",
"lug": "jul",
"ago": "aug",
"set": "sep",
"ott": "oct",
"nov": "nov",
"dic": "dec",
}, # noqa
"weekday": {
"sab": "sat",
"dom": "sun",
"lun": "mon",
"mar": "tue",
"mer": "wed",
"gio": "thu",
"ven": "fri",
}, # noqa
},
}