Compare commits
No commits in common. "9b03662b173ae017bfb222add885ad335f7521c0" and "4a3e8b60776ba12802ef44c38f70da8023c1895f" have entirely different histories.
9b03662b17
...
4a3e8b6077
@ -6,7 +6,6 @@ db = None
|
|||||||
|
|
||||||
def get_db():
|
def get_db():
|
||||||
global db
|
global db
|
||||||
|
if not db:
|
||||||
if db is None:
|
|
||||||
db = MongoClient(os.environ['MONGO_URL'])[os.environ['MONGO_DATABASE']]
|
db = MongoClient(os.environ['MONGO_URL'])[os.environ['MONGO_DATABASE']]
|
||||||
return db
|
return db
|
||||||
|
@ -129,15 +129,10 @@ def loads(wif_file):
|
|||||||
draft['warp'] = {}
|
draft['warp'] = {}
|
||||||
draft['warp']['shafts'] = weaving.getint('shafts')
|
draft['warp']['shafts'] = weaving.getint('shafts')
|
||||||
draft['warp']['threading'] = []
|
draft['warp']['threading'] = []
|
||||||
|
draft['warp']['defaultColour'] = draft['colours'][warp.getint('color')-1]
|
||||||
|
warp_colour_index = warp.getint('color') - 1
|
||||||
if warp.get('color'):
|
# In case of no color table or colour index out of bounds
|
||||||
warp_colour_index = warp.getint('color') - 1
|
draft['warp']['defaultColour'] = draft['colours'][warp_colour_index] if len(draft['colours']) > warp_colour_index else draft['colours'][0]
|
||||||
draft['warp']['defaultColour'] = draft['colours'][warp_colour_index]
|
|
||||||
|
|
||||||
else:
|
|
||||||
# In case of no color table or colour index out of bounds
|
|
||||||
draft['warp']['defaultColour'] = draft['colours'][0]
|
|
||||||
|
|
||||||
for x in threading:
|
for x in threading:
|
||||||
shaft = threading[x]
|
shaft = threading[x]
|
||||||
@ -160,13 +155,9 @@ def loads(wif_file):
|
|||||||
draft['weft'] = {}
|
draft['weft'] = {}
|
||||||
draft['weft']['treadles'] = weaving.getint('treadles')
|
draft['weft']['treadles'] = weaving.getint('treadles')
|
||||||
draft['weft']['treadling'] = []
|
draft['weft']['treadling'] = []
|
||||||
|
weft_colour_index = weft.getint('color') - 1
|
||||||
if weft.get('color'):
|
# In case of no color table or colour index out of bounds
|
||||||
weft_colour_index = weft.getint('color') - 1
|
draft['weft']['defaultColour'] = draft['colours'][weft_colour_index] if len(draft['colours']) > weft_colour_index else draft['colours'][1]
|
||||||
draft['weft']['defaultColour'] = draft['colours'][weft_colour_index]
|
|
||||||
else:
|
|
||||||
# In case of no color table or colour index out of bounds
|
|
||||||
draft['weft']['defaultColour'] = draft['colours'][1]
|
|
||||||
|
|
||||||
for x in treadling:
|
for x in treadling:
|
||||||
shaft = treadling[x]
|
shaft = treadling[x]
|
||||||
|
Loading…
Reference in New Issue
Block a user