Skip to content

Commit 2f91f2d

Browse files
committed
Initial commit of misc code
0 parents  commit 2f91f2d

14 files changed

+672
-0
lines changed

.gitattributes

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
* text=auto
2+
3+
# Documents
4+
*.doc diff=astextplain
5+
*.DOC diff=astextplain
6+
*.docx diff=astextplain
7+
*.DOCX diff=astextplain
8+
*.dot diff=astextplain
9+
*.DOT diff=astextplain
10+
*.pdf diff=astextplain
11+
*.PDF diff=astextplain
12+
*.rtf diff=astextplain
13+
*.RTF diff=astextplain
14+
*.md text
15+
*.adoc text
16+
*.textile text
17+
*.mustache text
18+
*.csv text
19+
*.tab text
20+
*.tsv text
21+
*.sql text
22+
23+
# Graphics
24+
*.png binary
25+
*.jpg binary
26+
*.jpeg binary
27+
*.gif binary
28+
*.tif binary
29+
*.tiff binary
30+
*.ico binary
31+
# SVG treated as an asset (binary) by default. If you want to treat it as text,
32+
# comment-out the following line and uncomment the line after.
33+
*.svg binary
34+
#*.svg text
35+
*.eps binary
36+
37+
#sources
38+
*.c text
39+
*.cc text
40+
*.cxx text
41+
*.cpp text
42+
*.c++ text
43+
*.hpp text
44+
*.h text
45+
*.h++ text
46+
*.hh text
47+
48+
# Compiled Object files
49+
*.slo binary
50+
*.lo binary
51+
*.o binary
52+
*.obj binary
53+
54+
# Precompiled Headers
55+
*.gch binary
56+
*.pch binary
57+
58+
# Compiled Dynamic libraries
59+
*.so binary
60+
*.dylib binary
61+
*.dll binary
62+
63+
# Compiled Static libraries
64+
*.lai binary
65+
*.la binary
66+
*.a binary
67+
*.lib binary
68+
69+
# Executables
70+
*.exe binary
71+
*.out binary
72+
*.app binary
73+
74+
# Source files
75+
# ============
76+
*.pxd text
77+
*.py text diff=python
78+
*.py3 text
79+
*.pyw text
80+
*.pyx text
81+
82+
# Binary files
83+
# ============
84+
*.db binary
85+
*.p binary
86+
*.pkl binary
87+
*.pyc binary
88+
*.pyd binary
89+
*.pyo binary
90+
91+
*.html text
92+
.project text
93+
94+
# M$ files
95+
*.bat text eol=crlf
96+
97+
*.gitignore text eol=crlf
98+
*.gitattributes text eol=crlf

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# svn
2+
.svn/
3+
4+
# binaries
5+
*.pyc
6+
*.pyo
7+
__pycache__/
8+
*.exe
9+
10+
# tmp
11+
*.log
12+
*.patch
13+
*.diff
14+
*.tmp
15+
16+
# Windows etc
17+
desktop.ini
18+
.dropbox
19+
20+
21+
# IDE files
22+
.idea/
23+
# if a symlink
24+
.idea

append_attr/append_attr.py

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
cellRecAttrs = {
2+
u'C.Acoustic': ('acousticSpace',),
3+
u'C.Climate': ('climate',),
4+
u'C.Encounter': ('encounterZone',),
5+
u'C.ImageSpace': ('imageSpace',),
6+
u'C.Location': ('location',),
7+
u'C.Music': ('music',),
8+
u'C.Name': ('full',),
9+
u'C.Owner': ('ownership',),
10+
u'C.RecordFlags': ('flags1',),
11+
u'C.SkyLighting': ('',),
12+
u'C.Regions': ('regions',),
13+
u'C.Water': ('water', 'waterHeight', 'waterNoiseTexture',
14+
'waterEnvironmentMap',),
15+
}
16+
cellRecFlags = {
17+
u'C.Acoustic': ('',),
18+
u'C.Climate': ('showSky',),
19+
u'C.Encounter': ('',),
20+
u'C.ImageSpace': ('',),
21+
u'C.Location': ('',),
22+
u'C.Music': ('',),
23+
u'C.Name': ('',),
24+
u'C.Owner': ('publicPlace',),
25+
u'C.RecordFlags': ('valu1', 'value2',),
26+
u'C.SkyLighting': ('useSkyLighting',),
27+
u'C.Regions': ('',),
28+
u'C.Water': ('hasWater',),
29+
}
30+
print cellRecAttrs
31+
print cellRecFlags
32+
print "cellRecAttrs:"
33+
for tags in cellRecAttrs:
34+
print "x: ", tags, ", atrs: ", cellRecAttrs[tags]
35+
print "Length of: ", tags, " = ", len(tags), \
36+
", Length of cellRecAttrs[x] : ", len(cellRecAttrs[tags])
37+
print
38+
# for attr in tags
39+
# print "This is attr: ", attr
40+
print
41+
print
42+
print "cellRecFlags:"
43+
for x in cellRecFlags:
44+
print "x: ", x, "atrs: ", cellRecFlags[x]
45+
print "Length of: ", x, " = ", len(x), \
46+
"Length of cellRecFlags[x] : ", len(cellRecFlags[x])
47+
print
48+
49+
list_of_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
50+
for list in list_of_lists:
51+
for x in list:
52+
print x
53+
print
54+
55+
56+
class Iterable(object):
57+
def __init__(self, values):
58+
self.values = values
59+
self.location = 0
60+
61+
def __iter__(self):
62+
return self
63+
64+
def next(self):
65+
if self.location == len(self.values):
66+
raise StopIteration
67+
value = self.values[self.location]
68+
self.location += 1
69+
return value
70+
71+
72+
attributes = ['water', 'waterHeight', 'waterNoiseTexture',
73+
'waterEnvironmentMap']
74+
print Iterable(attributes)
75+
print Iterable(attributes).next
76+
77+
print
78+
class print_hi_not_bye:
79+
def __init__(self):
80+
self.name = "King"
81+
82+
def hi(self):
83+
print(self.name)
84+
85+
class_alias = print_hi_not_bye()
86+
class_alias.hi() # prints King
87+
88+
print
89+
90+
answer = 11 / 3
91+
remainder = 11 % 3
92+
string1 = "the answer is"
93+
string2 = "with a remainder of"
94+
print "%s %d %s %d" % (string1, answer, string2, remainder)
95+
96+
print
97+
98+
astring = "Hello Big World!"
99+
print "Hello = ", astring[0:5]
100+
print "Big = ", astring[6:9]
101+
print "World = ", astring[10:16]
102+
print "H = ", astring[0]
103+
print "B = ", astring[6]
104+
print "W = ", astring[10]
105+
print "Just B = ", astring[6:9:3]
106+
print "B and g not i = ", astring[6:9:2]
107+
108+
word_array= ['R', 'e', 'd', ' ', 'T', 'w', 'o', ' ', 'B', 'i', 'g']
109+
print word_array
110+
print len(word_array)
111+
print
112+
113+
114+
#R | e | d | | T | w | o | | B | i | g
115+
#0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
116+
new_string = "Red Two Big"
117+
print "Red = ", new_string[-4:-0]
118+
print "Two = ", new_string[4:7]
119+
print "Big = ", new_string[8:11]
120+
print "RTB = ", new_string[0:10:4]
121+
print
122+
123+
new_string = "Red Two Big"
124+
print "g = ", new_string[-1]
125+
print "i = ", new_string[-2]
126+
print "B = ", new_string[-3]
127+
something = new_string[-1:-4]
128+
print len(something)
129+
print "[empty] = ", new_string[-1:-4]
130+
other = new_string[-4:-1]
131+
print len(other)
132+
print " Bi = ", other
133+

binarydata/binarydata.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from struct import *
2+
3+
def get_names(raw_data):
4+
i = 0
5+
offset = 1
6+
name_list = []
7+
num_strings, = unpack('B', raw_data[:1])
8+
while i < num_strings:
9+
name_len, = unpack('H', raw_data[offset:offset + 2])
10+
offset += 2
11+
name_data = raw_data[offset:offset + name_len]
12+
offset += name_len
13+
name_list.append(name_data.decode())
14+
i += 1
15+
return name_list
16+
17+
18+
def pack_names(names):
19+
numFileNames = len(names)
20+
print "count :", numFileNames
21+
dataBuff = []
22+
dataBuff.append(pack('B',numFileNames))
23+
for count in xrange(numFileNames):
24+
lenFileName = len(names[count])
25+
arrayFileName = names[count]
26+
print "lenFileName", lenFileName
27+
print "arrayFileName", arrayFileName
28+
dataBuff.append(pack('H',lenFileName))
29+
print "dataBuff", dataBuff
30+
31+
data = b'\x02\x1d\x00ccbgsfo4001-pipboy(black).esl\x1e\x00ccbgsfo4004-pipboy(camo02).esl'
32+
names = get_names(data)
33+
print(names)
34+
pack_names(names)

binarydata3/binarydata.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from struct import unpack
2+
3+
class ByteReader:
4+
def __init__(self, data):
5+
self.data = data
6+
self.offset = 0
7+
8+
def __getitem(self, index):
9+
return self.data[index]
10+
11+
def __len__(self):
12+
return len(self.data)
13+
14+
def read(self, n=-1):
15+
if n < 0:
16+
self.offset = len(self.data)
17+
if self.offset >= len(self.data):
18+
return None
19+
data = self.data[self.offset:self.offset + n]
20+
self.offset += n
21+
return data
22+
23+
data = b'\x02\x1d\x00ccbgsfo4001-pipboy(black).esl\x1e\x00ccbgsfo4004-pipboy(camo02).esl'
24+
data = ByteReader(data)
25+
26+
numStrings, = unpack('B', data.read(1))
27+
print("numStrings:", numStrings)
28+
for count in range(numStrings):
29+
print('nameLength:', nameLength)
30+

0 commit comments

Comments
 (0)