Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
parser = ap.ArgumentParser(
description="Generate single & multi-unit schematic symbols for KiCad from a CSV file."
)
parser.add_argument(
"-v", "--version", action="version", version="KiPart " + __version__
)
parser.add_argument(
"input_files",
nargs="+",
type=str,
metavar="file.[csv|txt|xlsx|zip]",
help="Files for parts in CSV/text/Excel format or as such files in .zip archives.",
)
parser.add_argument(
"-r",
"--reader",
nargs="?",
# type=str.lower,
type=lambda s: unicode(s).lower(),
choices=[
"generic",
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'KiPart'
copyright = u'2015, XESS Corp.'
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = kipart.pckg_info.__version__
# The full version, including alpha/beta/rc tags.
release = kipart.pckg_info.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to
# some non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'KiPart'
copyright = u'2015, XESS Corp.'
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = kipart.pckg_info.__version__
# The full version, including alpha/beta/rc tags.
release = kipart.pckg_info.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to
# some non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
def main():
parser = ap.ArgumentParser(
description="Convert a KiCad schematic symbol library file into a CSV file for KiPart."
)
parser.add_argument(
"-v", "--version", action="version", version="kilib2csv " + __version__
)
parser.add_argument(
"input_files",
nargs="+",
type=str,
metavar="file.lib",
help="KiCad schematic symbol library.",
)
parser.add_argument(
"-o",
"--output",
nargs="?",
type=str,
metavar="file.csv",
help="CSV file created from schematic library file.",
)
def main():
parser = ap.ArgumentParser(
description="Generate single & multi-unit schematic symbols for KiCad from a CSV file."
)
parser.add_argument(
"-v", "--version", action="version", version="KiPart " + __version__
)
parser.add_argument(
"input_files",
nargs="+",
type=str,
metavar="file1.[csv|zip] file2.[csv|zip] ...",
help="Files for parts in CSV format or as CSV files in .zip archives.",
)
parser.add_argument(
"-r",
"--reader",
nargs="?",
type=str.lower,
choices=[
"generic",
"xilinxultra",
def call_kipart(part_data_file):
"""Helper routine for calling kipart."""
return kipart(
reader_type=args.reader,
part_data_file=part_data_file,
parts_lib=parts_lib,
allow_overwrite=args.overwrite,
sort_type=args.sort,
reverse=args.reverse,
fuzzy_match=args.fuzzy_match,
bundle=args.bundle,
debug_level=args.debug,
)
DEFAULT_PIN.side = args.side
check_file_exists = True # Used to check for existence of a single output lib file.
for input_file in args.input_files:
# No explicit output lib file, so each individual input file will generate its own .lib file.
if check_file_exists or not args.output:
output_file = args.output or os.path.splitext(input_file)[0] + ".lib"
if os.path.isfile(output_file):
# The output lib file already exists.
if args.overwrite:
# Overwriting an existing file, so ignore the existing parts.
parts_lib = OrderedDict()
elif args.append:
# Appending to an existing file, so read in existing parts.
parts_lib = read_lib_file(output_file)
"style": "style",
"side": "side",
"unit": "unit",
"bank": "unit",
"hidden": "hidden",
"": "", # Blank column names stay blank.
}
# This is just a vanilla object class for device pins.
# We'll add attributes to it as needed.
class Pin(object):
pass
DEFAULT_PIN = Pin()
DEFAULT_PIN.num = None
DEFAULT_PIN.name = ""
DEFAULT_PIN.type = "io"
DEFAULT_PIN.style = "line"
DEFAULT_PIN.unit = 1
DEFAULT_PIN.side = "left"
DEFAULT_PIN.hidden = "no"
def num_row_elements(row):
"""Get number of elements in CSV row."""
try:
rowset = set(row)
rowset.discard("")
return len(rowset)
except TypeError: