-
Notifications
You must be signed in to change notification settings - Fork 0
/
Links.py
207 lines (140 loc) · 5.1 KB
/
Links.py
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# -*- coding: utf-8 -*-
"""
Created on Tue May 5 14:15:25 2020
@author: malrawi
Links
"""
# Pantone color catalouges and trends
# https://www.pantone.com/color-intelligence/fashion-color-trend-report/new-york-autumn-winter-2020-2021
# clo3d is like the autocad of clothing
# https://www.clo3d.com/explore/whyclo
# https://www.marvelousdesigner.com/
# 3D formtas
# https://support.clo3d.com/hc/en-us/articles/115002000227-Compatible-File-Format
# JSON ot svg https://vanya.jp.net/vtree/
# https://stackoverflow.com/questions/50846431/converting-a-yaml-file-to-python-json-object
# https://onlineyamltools.com/convert-yaml-to-json
# https://onlineyamltools.com/convert-yaml-to-xml
# http://yaml-online-parser.appspot.com/
# https://jsonformatter.org/json-parser
# yaml validator: http://www.yamllint.com/
# http://www.ic.gc.ca/eic/site/oca-bc.nsf/eng/ca02009.html#Washing
# https://pypi.org/project/dicttoxml/
# https://rollout.io/blog/yaml-tutorial-everything-you-need-get-started/
# https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-over-multiple-lines
'''
# very important on fabric make and types
https://www.textileschool.com/171/textile-fabric-types-comprehensive-list-of-textile-fabrics/
1- YAML Multi Documents
YAML format allows multiple documents to be embedded in a single file. They only have to be separated with a line containing triple-dash separator ---.
YAMLJSON
document: this is document 1
---
document: this is document 2
for details see https://gettaurus.org/docs/YAMLTutorial/
2- To check the correctness of the ymal file use:
https://github.com/adrienverge/yamllint
3- https://www.xmlvalidation.com/
https://stackabuse.com/reading-and-writing-xml-files-in-python/
import xml.etree.ElementTree as ET
# create the file structure
data = ET.Element('data')
items = ET.SubElement(data, 'items')
item1 = ET.SubElement(items, 'item')
item2 = ET.SubElement(items, 'item')
item1.set('name','item1')
item2.set('name','item2')
item1.text = 'item1abc'
item2.text = 'item2abc'
# create a new XML file with the results
mydata = ET.tostring(data)
myfile = open("items2.xml", "w")
myfile.write(mydata)
'''
"""
1-
YAML Multi Documents
YAML format allows multiple documents to be embedded in a single file. They only have to be separated with a line containing triple-dash separator ---.
YAMLJSON
document: this is document 1
---
document: this is document 2
for details see https://gettaurus.org/docs/YAMLTutorial/
2- To check the correctness of the ymal file use:
https://github.com/adrienverge/yamllint
"""
# YAML tags and Python types, and more in https://pyyaml.org/wiki/PyYAMLDocumentation
# The following table describes how nodes with different tags are converted to Python objects.
# YAML tag Python type
# Standard YAML tags
# !!null None
# !!bool bool
# !!int int or long (int in Python 3)
# !!float float
# !!binary str (bytes in Python 3)
# !!timestamp datetime.datetime
# !!omap, !!pairs list of pairs
# !!set set
# !!str str or unicode (str in Python 3)
# !!seq list
# !!map dict
# Python-specific tags
# !!python/none None
# !!python/bool bool
# !!python/bytes (bytes in Python 3)
# !!python/str str (str in Python 3)
# !!python/unicode unicode (str in Python 3)
# !!python/int int
# !!python/long long (int in Python 3)
# !!python/float float
# !!python/complex complex
# !!python/list list
# !!python/tuple tuple
# !!python/dict dict
# Complex Python tags
# !!python/name:module.name module.name
# !!python/module:package.module package.module
# !!python/object:module.cls module.cls instance
# !!python/object/new:module.cls module.cls instance
# !!python/object/apply:module.f value of f(...)
'''
to get to bytes you can use json.dumps(variables).encode('utf-8')
then to convert back from bytes you can use json.loads(s.decode('utf-8'))
read(file, 'ab') or 'rb+' , but seems 'r+b' for python2
'ab' forces all writes to happen at the end of the file. You probably want 'r+b'.
https://stackoverflow.com/questions/40890697/python3-reading-a-binary-file-4-bytes-at-a-time-and-xor-it-with-a-4-byte-long-k
https://stackoverflow.com/questions/4388201/how-to-seek-and-append-to-a-binary-file-in-python
using seek:
NOTE : Remember new bytes over write previous bytes
As per python 3 syntax
with open('myfile.dat', 'wb') as file:
b = bytearray(b'This is a sample')
file.write(b)
with open('myfile.dat', 'rb+') as file:
file.seek(5)
b1 = bytearray(b' text')
#remember new bytes over write previous bytes
file.write(b1)
with open('myfile.dat', 'rb') as file:
print(file.read())
OUTPUT
b'This textample'
remember new bytes over write previous bytes
'''
'''
def dict_to_binary(the_dict):
str = json.dumps(the_dict)
binary = ' '.join(format(ord(letter), 'b') for letter in str)
return binary
def binary_to_dict(the_binary):
jsn = ''.join(chr(int(x, 2)) for x in the_binary.split())
d = json.loads(jsn)
return d
bin = dict_to_binary(my_dict)
print (bin)
dct = binary_to_dict(bin)
print( dct)
will give the output
1111011 100010 1101011 100010 111010 100000 1011011 110001 101100 100000 110010 101100 100000 110011 1011101 1111101
{u'key': [1, 2, 3]}
'''