summaryrefslogtreecommitdiff
path: root/examples/elementtree/pickle.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:19:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 18:23:11 -0500
commit1e278de4cc9a4181e0747640a960e80efcea1ca9 (patch)
tree13d0c035807613bfa07e734acad79b9c843cb8b0 /examples/elementtree/pickle.py
parent1e1a38e7801f410f244e4bbb44ec795ae152e04e (diff)
downloadsqlalchemy-1e278de4cc9a4181e0747640a960e80efcea1ca9.tar.gz
Post black reformatting
Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
Diffstat (limited to 'examples/elementtree/pickle.py')
-rw-r--r--examples/elementtree/pickle.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/examples/elementtree/pickle.py b/examples/elementtree/pickle.py
index a86fe30e5..ca2c65504 100644
--- a/examples/elementtree/pickle.py
+++ b/examples/elementtree/pickle.py
@@ -1,31 +1,37 @@
-"""illustrates a quick and dirty way to persist an XML document expressed using ElementTree and pickle.
+"""
+illustrates a quick and dirty way to persist an XML document expressed using
+ElementTree and pickle.
This is a trivial example using PickleType to marshal/unmarshal the ElementTree
-document into a binary column. Compare to explicit.py which stores the individual components of the ElementTree
-structure in distinct rows using two additional mapped entities. Note that the usage of both
-styles of persistence are identical, as is the structure of the main Document class.
+document into a binary column. Compare to explicit.py which stores the
+individual components of the ElementTree structure in distinct rows using two
+additional mapped entities. Note that the usage of both styles of persistence
+are identical, as is the structure of the main Document class.
+
"""
-from sqlalchemy import (
- create_engine,
- MetaData,
- Table,
- Column,
- Integer,
- String,
- PickleType,
-)
-from sqlalchemy.orm import mapper, Session
+import os
+import sys
+from xml.etree import ElementTree
-import sys, os
+from sqlalchemy import Column
+from sqlalchemy import create_engine
+from sqlalchemy import Integer
+from sqlalchemy import MetaData
+from sqlalchemy import PickleType
+from sqlalchemy import String
+from sqlalchemy import Table
+from sqlalchemy.orm import mapper
+from sqlalchemy.orm import Session
-from xml.etree import ElementTree
e = create_engine("sqlite://")
meta = MetaData()
# setup a comparator for the PickleType since it's a mutable
# element.
+
+
def are_elements_equal(x, y):
return x == y
@@ -44,6 +50,8 @@ meta.create_all(e)
# our document class. contains a string name,
# and the ElementTree root element.
+
+
class Document(object):
def __init__(self, name, element):
self.filename = name
@@ -53,7 +61,7 @@ class Document(object):
# setup mapper.
mapper(Document, documents)
-###### time to test ! #########
+# time to test !
# get ElementTree document
filename = os.path.join(os.path.dirname(__file__), "test.xml")