Skip to content

Commit

Permalink
added docs string
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Oct 20, 2020
1 parent 46bcec2 commit daa84ba
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 95 deletions.
1 change: 0 additions & 1 deletion build/lib/m3u_parser/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion m3u_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .m3u_parser import M3uParser
from .m3u_parser import M3uParser
30 changes: 27 additions & 3 deletions m3u_parser/helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import asyncio
import csv
import re


# check if the regex is present or not
def is_present(regex, content):
match = re.search(re.compile(regex, flags=re.IGNORECASE), content)
Expand Down Expand Up @@ -48,13 +51,34 @@ def render_csv(header, data, out_path='output.csv'):
for i in data:
input.append(dict(i))
dict_writer.writerows(input)
return

# convert nested dictionary to csv

def ndict_to_csv(obj, output_path):
"""Convert nested dictionary to csv
:param obj: Stream information list
:type obj: list
:param output_path: Path to save the csv file.
:return: None
"""
tree = get_tree(obj)
if isinstance(obj, list):
header = [i[0] for i in tree[0]]
else:
header = [i[0] for i in tree]
return render_csv(header, tree, output_path)
render_csv(header, tree, output_path)


def run_until_completed(coros):
futures = [asyncio.ensure_future(c) for c in coros]

async def first_to_finish():
while True:
await asyncio.sleep(0)
for f in futures:
if f.done():
futures.remove(f)
return f.result()

while len(futures) > 0:
yield first_to_finish()
Loading

0 comments on commit daa84ba

Please sign in to comment.