Skip to content

Commit 0b92430

Browse files
committed
Converted to pep8
1 parent 88a7528 commit 0b92430

7 files changed

Lines changed: 51 additions & 55 deletions

File tree

doc/api.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
blocks indexed by id
88

9-
### blocksByName
9+
### blocks_name
1010

1111
blocks indexed by name
1212

13-
### blocksArray
13+
### blocks_list
1414

1515
unindexed blocks
1616

@@ -20,11 +20,11 @@ unindexed blocks
2020

2121
items indexed by id
2222

23-
### itemsByName
23+
### items_name
2424

2525
items indexed by name
2626

27-
### itemsArray
27+
### items_list
2828

2929
unindexed items
3030

@@ -34,7 +34,7 @@ unindexed items
3434

3535
biomes indexed by id
3636

37-
### biomesArray
37+
### biomes_list
3838

3939
unindexed biomes
4040

@@ -50,7 +50,7 @@ recipes indexed by id
5050

5151
instruments indexed by id
5252

53-
### instrumentsArray
53+
### instruments_list
5454

5555
unindexed instruments
5656

@@ -66,11 +66,11 @@ materials indexed by name
6666

6767
entities indexed by id
6868

69-
### entitiesByName
69+
### entities_name
7070

7171
entities indexed by name
7272

73-
### entitiesArray
73+
### entities_list
7474

7575
unindexed entities
7676

@@ -86,20 +86,16 @@ the minecraft protocol
8686

8787
windows indexed by id
8888

89-
### windowsByName
89+
### windows_name
9090

9191
windows indexed by name
9292

93-
### windowsArray
93+
### windows_list
9494

9595
unindexed windows
9696

9797
## Functions
9898

99-
### findItemOrBlockById
99+
### find_item_or_block
100100

101-
find a block or an item by its id
102-
103-
### findItemOrBlockByName
104-
105-
find a block or an item by its name
101+
find a block or an item by its id or name

doc/history.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.3.0
2+
* changed function names to follow pep8
3+
14
## 0.2.0
25
* add windows
36
* update protocol schema
@@ -8,4 +11,4 @@
811

912
## 0.1.0
1013
* provide : id-indexed data, name-indexed data, unindexed data and two functions to find items or blocks
11-
14+

example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
from minecraft_data.v1_8 import recipes
1+
from minecraft_data.v1_8 import find_item_or_block
22

3-
print(recipes["5"][0])
3+
print(find_item_or_block(1))
44

5-
from minecraft_data.v1_9 import recipes as recipes2
5+
print(find_item_or_block("stone"))
66

7-
print(recipes2["5"][0])
7+
from minecraft_data.v1_8 import recipes
88

9-
from minecraft_data.v1_8 import findItemOrBlockById, findItemOrBlockByName
9+
print(recipes["5"][0])
1010

11-
print(findItemOrBlockById(1))
11+
from minecraft_data.v1_8 import windows as windows
1212

13-
print(findItemOrBlockByName("stone"))
13+
print(windows["minecraft:brewing_stand"])
1414

15-
from minecraft_data.v1_8 import windows as windows
15+
from minecraft_data.v1_9 import recipes as recipes2
1616

17-
print(windows["minecraft:brewing_stand"])
17+
print(recipes2["5"][0])

minecraft_data/tools/__init__.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66
def convert(dir):
77
data = _grabdata(dir)
88
ret = {
9-
'blocks': _byId(data['blocks']),
10-
'blocksByName': _byName(data['blocks']),
11-
'blocksArray': data['blocks'],
12-
'items': _byId(data['items']),
13-
'itemsByName': _byName(data['items']),
14-
'itemsArray': data['items'],
15-
'biomes': _byId(data['biomes']),
16-
'biomesArray': data['biomes'],
9+
'blocks': _by_id(data['blocks']),
10+
'blocks_name': _by_name(data['blocks']),
11+
'blocks_list': data['blocks'],
12+
'items': _by_id(data['items']),
13+
'items_name': _by_name(data['items']),
14+
'items_list': data['items'],
15+
'biomes': _by_id(data['biomes']),
16+
'biomes_list': data['biomes'],
1717
'recipes': data['recipes'],
18-
'instruments': _byId(data['instruments']),
19-
'intrumentsArray': data['instruments'],
18+
'instruments': _by_id(data['instruments']),
19+
'instruments_list': data['instruments'],
2020
'materials': data['materials'],
21-
'entities': _byId(data['entities']),
22-
'entitiesByName': _byName(data['entities']),
23-
'entitiesArray': data['entities'],
21+
'entities': _by_id(data['entities']),
22+
'entities_name': _by_name(data['entities']),
23+
'entities_list': data['entities'],
2424
'protocol': data['protocol'],
25-
'windows': _byId(data['windows']),
26-
'windowsByName': _byName(data['windows']),
27-
'windowsArray': data['windows'],
25+
'windows': _by_id(data['windows']),
26+
'windows_name': _by_name(data['windows']),
27+
'windows_list': data['windows'],
2828
}
29-
def findItemOrBlockById(id):
30-
return findBy(id, ret['items'], ret['blocks'])
3129

32-
def findItemOrBlockByName(name):
33-
return findBy(name, ret['itemsByName'], ret['blocksByName'])
30+
def find_item_or_block(find):
31+
if isinstance(find, int): # by id
32+
return find_by(find, ret['items'], ret['blocks'])
33+
else: # by name
34+
return find_by(find, ret['items_name'], ret['blocks_name'])
3435

35-
ret['findItemOrBlockById'] = findItemOrBlockById
36-
ret['findItemOrBlockByName'] = findItemOrBlockByName
36+
ret['find_item_or_block'] = find_item_or_block
3737

3838
return ret
3939

@@ -48,21 +48,20 @@ def _grabdata(dir):
4848
return data
4949

5050

51-
def _byId(data):
51+
def _by_id(data):
5252
return _by('id', data)
5353

5454

55-
def _byName(data):
55+
def _by_name(data):
5656
return _by('name', data)
5757

5858

5959
def _by(key, data):
6060
return {item[key]: item for item in data}
6161

6262

63-
def findBy(key, *args):
63+
def find_by(key, *args):
6464
for arg in args:
6565
if key in arg:
6666
return arg[key]
6767
return None
68-

minecraft_data/v1_8/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88

99
for name, data in convert(_dir).items():
1010
setattr(sys.modules[__name__], name, data)
11-

minecraft_data/v1_9/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88

99
for name, data in convert(_dir).items():
1010
setattr(sys.modules[__name__], name, data)
11-

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
description='Provide easy access to minecraft data in python',
88
license='MIT',
99
long_description=open('README.rst').read(),
10-
version='0.2.0',
10+
version='0.3.0',
1111
maintainer='Romain Beaumont',
1212
maintainer_email='romain.rom1@gmail.com',
1313
url='https://github.com/rom1504/python-minecraft-data',

0 commit comments

Comments
 (0)