diff options
author | Filipp Lepalaan <f@0x00.co> | 2013-01-10 12:12:40 +0200 |
---|---|---|
committer | Filipp Lepalaan <f@0x00.co> | 2013-01-10 12:12:40 +0200 |
commit | 5ae6abdd194193744670e7684e9ce3ad63c3a619 (patch) | |
tree | 16c3a429e9ff08066acc45103f584cdc65d0d100 /gsx.py | |
parent | 74eb6d7b25fab193a1645fb1645a08c9aded62dd (diff) | |
download | py-gsxws-5ae6abdd194193744670e7684e9ce3ad63c3a619.tar.gz py-gsxws-5ae6abdd194193744670e7684e9ce3ad63c3a619.tar.bz2 py-gsxws-5ae6abdd194193744670e7684e9ce3ad63c3a619.zip |
Added locale
Diffstat (limited to 'gsx.py')
-rwxr-xr-x | gsx.py | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -13,8 +13,10 @@ logging.basicConfig(level=logging.INFO) logging.getLogger('suds.client').setLevel(logging.DEBUG) +# Must use a few module-level global variables CLIENT = None -SESSION = dict() # module-level variable +SESSION = dict() +LOCALE = 'en_XXX' def validate(value, what=None): """ @@ -60,6 +62,11 @@ class GsxObject(object): def set_method(self, new_method): self.method = new_method + def get_format(self): + df = open(os.path.join(os.path.dirname(__file__), 'langs.json'), 'r') + data = json.load(df) + return data[LOCALE] + def set_type(self, new_dt): """ Sets the object's primary data type to new_dt @@ -244,6 +251,16 @@ class Repair(GsxObject): def __init__(self, *args, **kwargs): super(Repair, self).__init__() + + formats = self.get_format() + + # native date types are not welcome here :) + for k, v in kwargs.items(): + if isinstance(v, date): + kwargs[k] = v.strftime(formats['df']) + if isinstance(v, time): + kwargs[k] = v.strftime(formats['tf']) + self.data = kwargs def create_carryin(self): @@ -256,7 +273,8 @@ class Repair(GsxObject): self.dt.customerAddress = self.data['customerAddress'] self.set_request('ns2:carryInRequestType', 'repairData') result = self.submit('CreateCarryInRepair') - print result + + return result.repairConfirmation def create_cnd(self): """ @@ -408,10 +426,12 @@ def init(env='ut', region='emea'): CLIENT = Client(url) def connect(user_id, password, sold_to, lang='en', tz='CEST', - env='ut', region='emea'): + env='ut', region='emea', locale=LOCALE): global SESSION - + global LOCALE + SESSION = {} + LOCALE = LOCALE init(env, region) |