Skip to content

Commit 89385cd

Browse files
committed
Fixing style in docstrings
1 parent 62e3640 commit 89385cd

File tree

1 file changed

+103
-51
lines changed

1 file changed

+103
-51
lines changed

src/mbed_os_tools/detect/lstools_base.py

Lines changed: 103 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@
3838

3939
def deprecated(reason):
4040
"""Deprecate a function/method with a decorator"""
41+
4142
def actual_decorator(func):
4243
@functools.wraps(func)
4344
def new_func(*args, **kwargs):
44-
logger.warning("Call to deprecated function %s. %s",
45-
func.__name__, reason)
45+
logger.warning("Call to deprecated function %s. %s", func.__name__, reason)
4646
return func(*args, **kwargs)
47+
4748
return new_func
49+
4850
return actual_decorator
4951

5052

@@ -588,82 +590,100 @@ def _run_cli_process(cmd, shell=True):
588590
_stdout, _stderr = p.communicate()
589591
return _stdout, _stderr, p.returncode
590592

591-
@deprecated("Functionality has been moved into 'list_mbeds'. "
592-
"Please use list_mbeds with 'unique_names=True' and "
593-
"'read_details_txt=True'")
593+
@deprecated(
594+
"Functionality has been moved into 'list_mbeds'. "
595+
"Please use list_mbeds with 'unique_names=True' and "
596+
"'read_details_txt=True'"
597+
)
594598
def list_mbeds_ext(self):
595599
"""! Function adds extra information for each mbed device
596-
@return Returns list of mbed devices plus extended data like 'platform_name_unique'
600+
@return Returns list of mbed devices plus extended data like
601+
'platform_name_unique'
597602
@details Get information about mbeds with extended parameters/info included
598603
"""
599604

600605
return self.list_mbeds(unique_names=True, read_details_txt=True)
601606

602-
@deprecated("List formatting methods are deprecated for a simpler API. "
603-
"Please use 'list_mbeds' instead.")
607+
@deprecated(
608+
"List formatting methods are deprecated for a simpler API. "
609+
"Please use 'list_mbeds' instead."
610+
)
604611
def list_manufacture_ids(self):
605612
"""! Creates list of all available mappings for target_id -> Platform
606613
@return String with table formatted output
607614
"""
608615
from prettytable import PrettyTable, HEADER
609616

610-
columns = ['target_id_prefix', 'platform_name']
617+
columns = ["target_id_prefix", "platform_name"]
611618
pt = PrettyTable(columns, junction_char="|", hrules=HEADER)
612619
for col in columns:
613-
pt.align[col] = 'l'
620+
pt.align[col] = "l"
614621

615622
for target_id_prefix, platform_name in sorted(self.plat_db.items()):
616623
pt.add_row([target_id_prefix, platform_name])
617624

618625
return pt.get_string()
619626

620-
@deprecated("List formatting methods are deprecated to simplify the API. "
621-
"Please use 'list_mbeds' instead.")
627+
@deprecated(
628+
"List formatting methods are deprecated to simplify the API. "
629+
"Please use 'list_mbeds' instead."
630+
)
622631
def list_platforms(self):
623-
"""! Useful if you just want to know which platforms are currently available on the system
632+
"""! Useful if you just want to know which platforms are currently
633+
available on the system
624634
@return List of (unique values) available platforms
625635
"""
626636
result = []
627637
mbeds = self.list_mbeds()
628638
for i, val in enumerate(mbeds):
629-
platform_name = str(val['platform_name'])
639+
platform_name = str(val["platform_name"])
630640
if platform_name not in result:
631641
result.append(platform_name)
632642
return result
633643

634-
@deprecated("List formatting methods are deprecated to simplify the API. "
635-
"Please use 'list_mbeds' instead.")
644+
@deprecated(
645+
"List formatting methods are deprecated to simplify the API. "
646+
"Please use 'list_mbeds' instead."
647+
)
636648
def list_platforms_ext(self):
637-
"""! Useful if you just want to know how many platforms of each type are currently available on the system
649+
"""! Useful if you just want to know how many platforms of each type are
650+
currently available on the system
638651
@return Dict of platform: platform_count
639652
"""
640653
result = {}
641654
mbeds = self.list_mbeds()
642655
for i, val in enumerate(mbeds):
643-
platform_name = str(val['platform_name'])
656+
platform_name = str(val["platform_name"])
644657
if platform_name not in result:
645658
result[platform_name] = 1
646659
else:
647660
result[platform_name] += 1
648661
return result
649662

650-
@deprecated("List formatting methods are deprecated to simplify the API. "
651-
"Please use 'list_mbeds' instead.")
663+
@deprecated(
664+
"List formatting methods are deprecated to simplify the API. "
665+
"Please use 'list_mbeds' instead."
666+
)
652667
def list_mbeds_by_targetid(self):
653668
"""! Get information about mbeds with extended parameters/info included
654-
@return Returns dictionary where keys are TargetIDs and values are mbed structures
669+
@return Returns dictionary where keys are TargetIDs and values are mbed
670+
structures
655671
@details Ordered by target id (key: target_id).
656672
"""
657673
result = {}
658674
mbed_list = self.list_mbeds_ext()
659675
for mbed in mbed_list:
660-
target_id = mbed['target_id']
676+
target_id = mbed["target_id"]
661677
result[target_id] = mbed
662678
return result
663679

664-
@deprecated("List formatting methods are deprecated to simplify the API. "
665-
"Please use 'list_mbeds' instead.")
666-
def get_string(self, border=False, header=True, padding_width=1, sortby='platform_name'):
680+
@deprecated(
681+
"List formatting methods are deprecated to simplify the API. "
682+
"Please use 'list_mbeds' instead."
683+
)
684+
def get_string(
685+
self, border=False, header=True, padding_width=1, sortby="platform_name"
686+
):
667687
"""! Printing with some sql table like decorators
668688
@param border Table border visibility
669689
@param header Table header visibility
@@ -672,29 +692,43 @@ def get_string(self, border=False, header=True, padding_width=1, sortby='platfor
672692
@return Returns string which can be printed on console
673693
"""
674694
from prettytable import PrettyTable, HEADER
675-
result = ''
695+
696+
result = ""
676697
mbeds = self.list_mbeds(unique_names=True, read_details_txt=True)
677698
if mbeds:
678-
""" ['platform_name', 'mount_point', 'serial_port', 'target_id'] - columns generated from USB auto-detection
679-
['platform_name_unique', ...] - columns generated outside detection subsystem (OS dependent detection)
699+
""" ['platform_name', 'mount_point', 'serial_port', 'target_id'] -
700+
columns generated from USB auto-detection
701+
['platform_name_unique', ...] -
702+
columns generated outside detection subsystem (OS dependent detection)
680703
"""
681-
columns = ['platform_name', 'platform_name_unique', 'mount_point', 'serial_port', 'target_id', 'daplink_version']
704+
columns = [
705+
"platform_name",
706+
"platform_name_unique",
707+
"mount_point",
708+
"serial_port",
709+
"target_id",
710+
"daplink_version",
711+
]
682712
pt = PrettyTable(columns, junction_char="|", hrules=HEADER)
683713
for col in columns:
684-
pt.align[col] = 'l'
714+
pt.align[col] = "l"
685715

686716
for mbed in mbeds:
687717
row = []
688718
for col in columns:
689-
row.append(mbed[col] if col in mbed and mbed[col] else 'unknown')
719+
row.append(mbed[col] if col in mbed and mbed[col] else "unknown")
690720
pt.add_row(row)
691-
result = pt.get_string(border=border, header=header, padding_width=padding_width, sortby=sortby)
721+
result = pt.get_string(
722+
border=border, header=header, padding_width=padding_width, sortby=sortby
723+
)
692724
return result
693725

694726
# Private functions supporting API
695727

696-
@deprecated("This method will be removed from the public API. "
697-
"Please use 'list_mbeds' instead")
728+
@deprecated(
729+
"This method will be removed from the public API. "
730+
"Please use 'list_mbeds' instead"
731+
)
698732
def get_json_data_from_file(self, json_spec_filename, verbose=False):
699733
"""! Loads from file JSON formatted string to data structure
700734
@return None if JSON can be loaded
@@ -704,51 +738,69 @@ def get_json_data_from_file(self, json_spec_filename, verbose=False):
704738
try:
705739
return json.load(data_file)
706740
except ValueError as json_error_msg:
707-
logger.error("Parsing file(%s): %s", json_spec_filename, json_error_msg)
741+
logger.error(
742+
"Parsing file(%s): %s", json_spec_filename, json_error_msg
743+
)
708744
return None
709745
except IOError as fileopen_error_msg:
710746
logger.warning(fileopen_error_msg)
711747
return None
712748

713-
@deprecated("This method will be removed from the public API. "
714-
"Please use 'list_mbeds' instead")
749+
@deprecated(
750+
"This method will be removed from the public API. "
751+
"Please use 'list_mbeds' instead"
752+
)
715753
def get_htm_target_id(self, mount_point):
716754
target_id, _ = self._read_htm_ids(mount_point)
717755
return target_id
718756

719-
@deprecated("This method will be removed from the public API. "
720-
"Please use 'list_mbeds' instead")
757+
@deprecated(
758+
"This method will be removed from the public API. "
759+
"Please use 'list_mbeds' instead"
760+
)
721761
def get_mbed_htm(self, mount_point):
722762
_, build_info = self._read_htm_ids(mount_point)
723763
return build_info
724764

725-
@deprecated("This method will be removed from the public API. "
726-
"Please use 'list_mbeds' instead")
765+
@deprecated(
766+
"This method will be removed from the public API. "
767+
"Please use 'list_mbeds' instead"
768+
)
727769
def get_mbed_htm_comment_section_ver_build(self, line):
728770
return self._mbed_htm_comment_section_ver_build(line)
729771

730-
@deprecated("This method will be removed from the public API. "
731-
"Please use 'list_mbeds' instead")
772+
@deprecated(
773+
"This method will be removed from the public API. "
774+
"Please use 'list_mbeds' instead"
775+
)
732776
def get_mbed_htm_lines(self, mount_point):
733777
return self._htm_lines(mount_point)
734778

735-
@deprecated("This method will be removed from the public API. "
736-
"Please use 'list_mbeds' instead")
779+
@deprecated(
780+
"This method will be removed from the public API. "
781+
"Please use 'list_mbeds' instead"
782+
)
737783
def get_details_txt(self, mount_point):
738784
return self._details_txt(mount_point)
739785

740-
@deprecated("This method will be removed from the public API. "
741-
"Please use 'list_mbeds' instead")
786+
@deprecated(
787+
"This method will be removed from the public API. "
788+
"Please use 'list_mbeds' instead"
789+
)
742790
def parse_details_txt(self, lines):
743791
return self._parse_details(lines)
744792

745-
@deprecated("This method will be removed from the public API. "
746-
"Please use 'list_mbeds' instead")
793+
@deprecated(
794+
"This method will be removed from the public API. "
795+
"Please use 'list_mbeds' instead"
796+
)
747797
def scan_html_line_for_target_id(self, line):
748798
return self._target_id_from_htm(line)
749799

750800
@staticmethod
751-
@deprecated("This method will be removed from the public API. "
752-
"Please use 'list_mbeds' instead")
801+
@deprecated(
802+
"This method will be removed from the public API. "
803+
"Please use 'list_mbeds' instead"
804+
)
753805
def run_cli_process(cmd, shell=True):
754806
return MbedLsToolsBase._run_cli_process(cmd, shell)

0 commit comments

Comments
 (0)