6.16. Misc¶
6.16.1. ConcatText¶
-
class
easydata.parsers.misc.
ConcatText
(*args: Union[easydata.parsers.base.Base, easydata.parsers.base.BaseData, Callable], separator: str = ' ')[source]¶ Bases:
easydata.parsers.clause.OR
ConcatText
will combine string values of two or more parsers.
Example:
>>> import easydata as ed
Lets write our ConcatText
parser.
test_html = '''
<p class="brand">EasyData</p>
<p id="name">Easybook Pro 13</p>
'''
concat_text_parser = ed.ConcatText(
ed.Text(ed.pq('#name::text')),
ed.Text(ed.pq('.brand::text'))
)
Now lets parse test_html
data and print our result.
print(concat_text_parser.parse(test_html))
'EasyData Easybook Pro 13'
Parameters
6.16.2. JoinList¶
-
class
easydata.parsers.misc.
JoinList
(*args, strict_none: bool = False)[source]¶ Bases:
easydata.parsers.clause.OR
JoinList
is similar to JoinText
but instead of joining two str
together, it will join two list
types together.
Example:
>>> import easydata as ed
Lets write our JoinList
parser.
test_dict = {
'features': [
'gold color',
'retina'
],
'specs': [
'i7 proc',
'16 gb'
]
}
join_list_parser = ed.JoinList(
ed.List(
ed.jp('features'),
parser=parsers.Text()
),
ed.List(
ed.jp('specs'),
parser=parsers.Text()
),
)
Now lets parse test_dict
data and print our result.
print(join_list_parser.parse(test_dict))
['gold color', 'retina', 'i7 proc', '16 gb']
6.16.3. MergeDict¶
-
class
easydata.parsers.misc.
MergeDict
(*args, strict_none: bool = False)[source]¶ Bases:
easydata.parsers.clause.OR
MergeDict
is similar to JoinList
but instead of joining two list
types together, it will merge two dict
types together.
Example:
>>> import easydata as ed
Lets write our MergeDict
parser.
test_dict = {
'features': {
'color': 'gold',
'display': 'retina'
},
'specs': {
'proc': 'i7',
'ram': '16 gb'
}
}
merge_dict_parser = ed.MergeDict(
ed.Dict(
ed.jp('features'),
key_parser=ed.Text(),
val_parser=ed.Text()
),
ed.Dict(
ed.jp('specs'),
key_parser=ed.Text(),
val_parser=ed.Text()
),
)
Now lets parse test_dict
data and print our result.
print(merge_dict_parser.parse(test_dict))
{'color': 'gold', 'display': 'retina', 'proc': 'i7', 'ram': '16 gb'}
6.16.4. ItemDict¶
-
class
easydata.parsers.misc.
ItemDict
(ignore_non_values: bool = False, exception_on_non_values: bool = False, **kwargs)[source]¶ Bases:
easydata.parsers.base.Base
examples coming soon …
Parameters¶
-
ignore_non_values
¶
-
exception_on_non_values
¶
6.16.5. ValueList¶
-
class
easydata.parsers.misc.
ValueList
(*args: Union[easydata.parsers.base.Base, easydata.parsers.base.BaseData, Callable], ignore_non_values: bool = True)[source]¶ Bases:
easydata.parsers.base.Base
examples coming soon …
Parameters¶
-
ignore_non_values
¶
6.16.6. StringFormat¶
-
class
easydata.parsers.misc.
StringFormat
(string: str, exception_on_non_values: bool = True, **kwargs)[source]¶
examples coming soon …
Parameters¶
-
exception_on_non_values
¶