8000 :books: update example to python 3.6 · blog2i2j/pyexcel.._..pyexcel@ce7342b · GitHub
[go: up one dir, main page]

Skip to content

Commit ce7342b

Browse files
committed
📚 update example to python 3.6
1 parent c71f57f commit ce7342b

File tree

9 files changed

+71
-80
lines changed

9 files changed

+71
-80
lines changed

.moban.d/one-liners.rst.jj2

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ And let's check what do we have:
6565

6666
.. code-block:: python
6767

68-
>>> for record in records:
69-
... print("%s of %s has %s mg" % (
70-
... record['Serving Size'],
71-
... record['Coffees'],
72-
... record['Caffeine (mg)']))
68+
>>> for r in records:
69+
... print(f"{r['Serving Size']} of {r['Coffees']} has {r['Caffeine (mg)']} mg")
7370
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
7471
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
7572
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -84,10 +81,7 @@ Instead, what if you have to use `pyexcel.get_array` to do the same:
8481
.. code-block:: python
8582

8683
>>> for row in p.get_array(file_name="your_file.xls", start_row=1):
87-
... print("%s of %s has %s mg" % (
88-
... row[1],
89-
... row[0],
90-
... row[2]))
84+
... print(f"{row[1]} of {row[0]} has {row[2]} mg")
9185
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
9286
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
9387
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg

.moban.d/partial-data.rst.jj2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,16 @@ to "your_file.xls" but increase each element by 1.
136136

137137
What we can do is to define a row renderer function as the following:
138138

139+
.. code-block:: python
140+
139141
>>> def increment_by_one(row):
140142
... for element in row:
141143
... yield element + 1
142144

143145
Then pass it onto save_as function using row_renderer:
144146

147+
.. code-block:: python
148+
145149
>>> pe.isave_as(file_name="your_file.csv",
146150
... row_renderer=increment_by_one,
147151
... dest_file_name="your_file.xlsx")

.moban.d/two-liners.rst.jj2

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,13 @@ And let's check what do we have:
6969
.. code-block:: python
7070

7171
>>> for record in records:
72-
... print("%s of %s has %s mg" % (
73-
... record['Serving Size'],
74-
... record['Coffees'],
75-
... record['Caffeine (mg)']))
72+
... print(f"{r['Serving Size']} of {r['Coffees']} has {r['Caffeine (mg)']} mg")
7673
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
7774
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
7875
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
7976
regular(16 oz.) of Panera Coffee Light Roast has 300 mg
8077

81-
Please do not forgot the second line:
78+
Please do not forgot the second line to close the opened file handle:
8279

8380
.. code-block:: python
8481

@@ -92,10 +89,7 @@ Instead, what if you have to use `pyexcel.get_array` to do the same:
9289
.. code-block:: python
9390

9491
>>> for row in p.iget_array(file_name="your_file.xls", start_row=1):
95-
... print("%s of %s has %s mg" % (
96-
... row[1],
97-
... row[0],
98-
... row[2]))
92+
... print(f"{row[1]} of {row[0]} has {row[2]} mg")
9993
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
10094
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
10195
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -328,7 +322,7 @@ Again it is really simple. Let's verify what we have gotten:
328322
| Smith | 4.2 | 12/11/14 |
329323
+-------+--------+----------+
330324

331-
.. NOTE::
325+
.. note::
332326

333327
Please note that csv(comma separate value) file is pure text file. Formula, charts, images and formatting in xls file will disappear no matter which transcoding tool you use. Hence, pyexcel is a quick alternative for this transcoding job.
334328

README.rst

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,8 @@ And let's check what do we have:
135135

136136
.. code-block:: python
137137
138-
>>> for record in records:
139-
... print("%s of %s has %s mg" % (
140-
... record['Serving Size'],
141-
... record['Coffees'],
142-
... record['Caffeine (mg)']))
138+
>>> for r in records:
139+
... print(f"{r['Serving Size']} of {r['Coffees']} has {r['Caffeine (mg)']} mg")
143140
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
144141
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
145142
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -154,10 +151,7 @@ Instead, what if you have to use `pyexcel.get_array` to do the same:
154151
.. code-block:: python
155152
156153
>>> for row in p.get_array(file_name="your_file.xls", start_row=1):
157-
... print("%s of %s has %s mg" % (
158-
... row[1],
159-
... row[0],
160-
... row[2]))
154+
... print(f"{row[1]} of {row[0]} has {row[2]} mg")
161155
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
162156
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
163157
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -656,12 +650,16 @@ to "your_file.xls" but increase each element by 1.
656650

657651
What we can do is to define a row renderer function as the following:
658652

653+
.. code-block:: python
654+
659655
>>> def increment_by_one(row):
660656
... for element in row:
661657
... yield element + 1
662658
663659
Then pass it onto save_as function using row_renderer:
664660

661+
.. code-block:: python
662+
665663
>>> pe.isave_as(file_name="your_file.csv",
666664
... row_renderer=increment_by_one,
667665
... dest_file_name="your_file.xlsx")
@@ -733,16 +731,13 @@ And let's check what do we have:
733731
.. code-block:: python
734732
735733
>>> for record in records:
736-
... print("%s of %s has %s mg" % (
737-
... record['Serving Size'],
738-
... record['Coffees'],
739-
... record['Caffeine (mg)']))
734+
... print(f"{r['Serving Size']} of {r['Coffees']} has {r['Caffeine (mg)']} mg")
740735
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
741736
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
742737
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
743738
regular(16 oz.) of Panera Coffee Light Roast has 300 mg
744739
745-
Please do not forgot the second line:
740+
Please do not forgot the second line to close the opened file handle:
746741

747742
.. code-block:: python
748743
@@ -756,10 +751,7 @@ Instead, what if you have to use `pyexcel.get_array` to do the same:
756751
.. code-block:: python
757752
758753
>>> for row in p.iget_array(file_name="your_file.xls", start_row=1):
759-
... print("%s of %s has %s mg" % (
760-
... row[1],
761-
... row[0],
762-
... row[2]))
754+
... print(f"{row[1]} of {row[0]} has {row[2]} mg")
763755
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
764756
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
765757
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -969,7 +961,7 @@ Again it is really simple. Let's verify what we have gotten:
969961
| Smith | 4.2 | 12/11/14 |
970962
+-------+--------+----------+
971963
972-
.. NOTE::
964+
.. note::
973965

974966
Please note that csv(comma separate value) file is pure text file. Formula, charts, images and formatting in xls file will disappear no matter which transcoding tool you use. Hence, pyexcel is a quick alternative for this transcoding job.
975967

docs/source/bigdata.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,16 @@ to "your_file.xls" but increase each element by 1.
128128

129129
What we can do is to define a row renderer function as the following:
130130

131+
.. code-block:: python
132+
131133
>>> def increment_by_one(row):
132134
... for element in row:
133135
... yield element + 1
134136
135137
Then pass it onto save_as function using row_renderer:
136138

139+
.. code-block:: python
140+
137141
>>> pe.isave_as(file_name="your_file.csv",
138142
... row_renderer=increment_by_one,
139143
... dest_file_name="your_file.xlsx")

docs/source/quickstart.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ And let's check what do we have:
5050

5151
.. code-block:: python
5252
53-
>>> for record in records:
54-
... print("%s of %s has %s mg" % (
55-
... record['Serving Size'],
56-
... record['Coffees'],
57-
... record['Caffeine (mg)']))
53+
>>> for r in records:
54+
... print(f"{r['Serving Size']} of {r['Coffees']} has {r['Caffeine (mg)']} mg")
5855
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
5956
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
6057
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -69,10 +66,7 @@ Instead, what if you have to use `pyexcel.get_array` to do the same:
6966
.. code-block:: python
7067
7168
>>> for row in p.get_array(file_name="your_file.xls", start_row=1):
72-
... print("%s of %s has %s mg" % (
73-
... row[1],
74-
... row[0],
75-
... row[2]))
69+
... print(f"{row[1]} of {row[0]} has {row[2]} mg")
7670
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
7771
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
7872
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg

docs/source/two-liners.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,13 @@ And let's check what do we have:
5353
.. code-block:: python
5454
5555
>>> for record in records:
56-
... print("%s of %s has %s mg" % (
57-
... record['Serving Size'],
58-
... record['Coffees'],
59-
... record['Caffeine (mg)']))
56+
... print(f"{r['Serving Size']} of {r['Coffees']} has {r['Caffeine (mg)']} mg")
6057
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
6158
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
6259
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
6360
regular(16 oz.) of Panera Coffee Light Roast has 300 mg
6461
65-
Please do not forgot the second line:
62+
Please do not forgot the second line to close the opened file handle:
6663

6764
.. code-block:: python
6865
@@ -76,10 +73,7 @@ Instead, what if you have to use `pyexcel.get_array` to do the same:
7673
.. code-block:: python
7774
7875
>>> for row in p.iget_array(file_name="your_file.xls", start_row=1):
79-
... print("%s of %s has %s mg" % (
80-
... row[1],
81-
... row[0],
82-
... row[2]))
76+
... print(f"{row[1]} of {row[0]} has {row[2]} mg")
8377
venti(20 oz) of Starbucks Coffee Blonde Roast has 475 mg
8478
large(20 oz.) of Dunkin' Donuts Coffee with Turbo Shot has 398 mg
8579
grande(16 oz.) of Starbucks Coffee Pike Place Roast has 310 mg
@@ -308,7 +302,7 @@ Again it is really simple. Let's verify what we have gotten:
308302
| Smith | 4.2 | 12/11/14 |
309303
+-------+--------+----------+
310304
311-
.. NOTE::
305+
.. note::
312306

313307
Please note that csv(comma separate value) file is pure text file. Formula, charts, images and formatting in xls file will disappear no matter which transcoding tool you use. Hence, pyexcel is a quick alternative for this transcoding job.
314308

pyexcel/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.6.2"
2-
__author__ = "C.W."
1+
__version__ = '0.6.2'
2+
__author__ = 'C.W.'

setup.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,62 @@
3636
EMAIL = "info@pyexcel.org"
3737
LICENSE = "New BSD"
3838
DESCRIPTION = (
39-
"A wrapper library that provides one API to read, manipulate and write"
40-
+ "data in different excel formats"
39+
"A wrapper library that provides one API to read, manipulate and write" +
40+
"data in different excel formats"
4141
)
4242
URL = "https://github.com/pyexcel/pyexcel"
4343
DOWNLOAD_URL = "%s/archive/0.6.2.tar.gz" % URL
4444
FILES = ["README.rst", "CHANGELOG.rst"]
45-
KEYWORDS = ["python", "tsv", "tsvz" "csv", "csvz", "xls", "xlsx", "ods"]
45+
KEYWORDS = [
46+
"python",
47+
'tsv',
48+
'tsvz'
49+
'csv',
50+
'csvz',
51+
'xls',
52+
'xlsx',
53+
'ods'
54+
]
4655

4756
CLASSIFIERS = [
4857
"Topic :: Software Development :: Libraries",
4958
"Programming Language :: Python",
5059
"Intended Audience :: Developers",
60+
5161
"Programming Language :: Python :: 3 :: Only",
62+
63+
64+
5265
"Programming Language :: Python :: 3.6",
5366
"Programming Language :: Python :: 3.7",
5467
"Programming Language :: Python :: 3.8",
55-
"Development Status :: 3 - Alpha",
68+
69+
'Development Status :: 3 - Alpha',
5670
]
5771

5872
PYTHON_REQUIRES = ">=3.6"
5973

60-
INSTALL_REQUIRES = ["lml>=0.0.4", "pyexcel-io>=0.5.19", "texttable>=0.8.2"]
74+
INSTALL_REQUIRES = [
75+
"lml>=0.0.4",
76+
"pyexcel-io>=0.5.19",
77+
"texttable>=0.8.2",
78+
]
6179
SETUP_COMMANDS = {}
6280

6381
PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests", "tests.*"])
6482
EXTRAS_REQUIRE = {
65-
"xls": ["pyexcel-xls>=0.5.0"],
66-
"xlsx": ["pyexcel-xlsx>=0.5.0"],
67-
"ods": ["pyexcel-ods3>=0.5.0"],
83+
"xls": ['pyexcel-xls>=0.5.0'],
84+
"xlsx": ['pyexcel-xlsx>=0.5.0'],
85+
"ods": ['pyexcel-ods3>=0.5.0'],
6886
}
6987
# You do not need to read beyond this line
70-
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(
71-
sys.executable
72-
)
73-
GS_COMMAND = "gs pyexcel v0.6.2 " + "Find 0.6.2 in changelog for more details"
74-
NO_GS_MESSAGE = (
75-
"Automatic github release is disabled. "
76-
+ "Please install gease to enable it."
77-
)
88+
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
89+
GS_COMMAND = ("gs pyexcel v0.6.2 " +
90+
"Find 0.6.2 in changelog for more details")
91+
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
92+
"Please install gease to enable it.")
7893
UPLOAD_FAILED_MSG = (
79-
'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND
80-
)
94+
'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND)
8195
HERE = os.path.abspath(os.path.dirname(__file__))
8296

8397

@@ -120,7 +134,9 @@ def run(self):
120134
sys.exit()
121135

122136

123-
SETUP_COMMANDS.update({"publish": PublishCommand})
137+
SETUP_COMMANDS.update({
138+
"publish": PublishCommand
139+
})
124140

125141

126142
def has_gease():
@@ -131,7 +147,6 @@ def has_gease():
131147
"""
132148
try:
133149
import gease # noqa
134-
135150
return True
136151
except ImportError:
137152
return False
@@ -200,5 +215,5 @@ def filter_out_test_code(file_handle):
200215
include_package_data=True,
201216
zip_safe=False,
202217
classifiers=CLASSIFIERS,
203-
cmdclass=SETUP_COMMANDS,
218+
cmdclass=SETUP_COMMANDS
204219
)

0 commit comments

Comments
 (0)
0