mirror of
https://github.com/mon/kbinxml.git
synced 2026-08-13 20:35:30 -05:00
Now an installable package!
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
*.pyc
|
||||
dist/
|
||||
kbinxml.egg-info/
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
An encoder/decoder for Konami's binary XML format, used in some of their games.
|
||||
|
||||
### Setup:
|
||||
`pip install bitarray lxml`
|
||||
|
||||
Additionally for Python 2:
|
||||
`pip install future`
|
||||
`pip install .`
|
||||
|
||||
```python
|
||||
In [1]: from kbinxml import KBinXML
|
||||
@@ -17,4 +14,6 @@ Out[4]: b'\xa0B\x80\x7f\x00\x00\x00\x08\x0b\x04\xdfM9\xfe\xff\x00\x00\x00\x00\x1
|
||||
In [5]: bin = KBinXML(Out[4])
|
||||
In [6]: bin.to_text()
|
||||
Out[7]: u'<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<root __type="str">Hello, world!</root>\n'
|
||||
```
|
||||
```
|
||||
|
||||
You can also use `kbinxml` from the commandline to convert files.
|
||||
1
kbinxml/__init__.py
Normal file
1
kbinxml/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .kbinxml import KBinXML, main
|
||||
@@ -7,9 +7,10 @@ import operator
|
||||
from io import BytesIO
|
||||
|
||||
import lxml.etree as etree
|
||||
from bytebuffer import ByteBuffer
|
||||
from sixbit import pack_sixbit, unpack_sixbit
|
||||
from format_ids import xml_formats, xml_types
|
||||
|
||||
from .bytebuffer import ByteBuffer
|
||||
from .sixbit import pack_sixbit, unpack_sixbit
|
||||
from .format_ids import xml_formats, xml_types
|
||||
|
||||
stdout = getattr(sys.stdout, 'buffer', sys.stdout)
|
||||
|
||||
@@ -309,7 +310,7 @@ class KBinXML():
|
||||
# because we need the 'real' root
|
||||
self.xml_doc = self.xml_doc[0]
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print('bin_xml.py file.[xml/bin]')
|
||||
exit()
|
||||
@@ -322,3 +323,6 @@ if __name__ == '__main__':
|
||||
stdout.write(xml.to_text().encode('utf-8'))
|
||||
else:
|
||||
stdout.write(xml.to_binary())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,4 +1,4 @@
|
||||
from kbinxml import KBinXML
|
||||
from .kbinxml import KBinXML
|
||||
# python 2/3 cross compat
|
||||
from io import open
|
||||
|
||||
23
setup.py
Normal file
23
setup.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from setuptools import setup
|
||||
import sys
|
||||
|
||||
|
||||
requires = [
|
||||
'bitarray',
|
||||
'lxml',
|
||||
]
|
||||
if sys.version_info < (3,0):
|
||||
requires.append('future')
|
||||
|
||||
setup(
|
||||
name='kbinxml',
|
||||
version='1.0',
|
||||
entry_points = {
|
||||
'console_scripts': ['kbinxml=kbinxml:main'],
|
||||
},
|
||||
packages=['kbinxml'],
|
||||
url='https://github.com/mon/kbinxml/',
|
||||
author='mon',
|
||||
author_email='me@mon.im',
|
||||
install_requires=requires
|
||||
)
|
||||
Reference in New Issue
Block a user