Skip to content

Commit

Permalink
[Fixed] Typos
Browse files Browse the repository at this point in the history
- Also a few style details
  • Loading branch information
set-soft committed Jan 8, 2024
1 parent 3666807 commit 437141f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 46 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Option to skip pages without diff

### Fixed
- Problems when using the plug-in and comparing uncommited stuff.
- Problems when using the plug-in and comparing uncommitted stuff.


## [2.4.1] - 2022-08-31
Expand Down Expand Up @@ -124,5 +124,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.0.0] - 2020-03-03
### Added
- Initial release


64 changes: 34 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ output directory.
For SCHs the process is similar, but using KiAuto. Note that one schematic is
compared at a time. The `--all_pages` option allows comparing multiple pages.
In this case adding or removing pages is only supported when the
`rsvg-convert` tool is available. Also note that this can't be done by the
git plug-in because git extracts only the file you want to compare.
Consult the advanced use explanation.
`rsvg-convert` tool is available. Also note that this can't be done by the git
plug-in because git extracts only the file you want to compare. Consult the
advanced use explanation.

The default resolution for the images is 150 DPI. It can be increased for
better images, at the cost of (exponetially) longer execution times. You can
better images, at the cost of (exponentially) longer execution times. You can
provide a smaller resolution for faster processing. For high resolution you
could need to configure the ImageMagick limits. Consult the 'identify -list
resource' command.
Expand Down Expand Up @@ -52,7 +52,9 @@ In a Debian/Ubuntu system you'll first need to add this
$ sudo apt-get install kidiff`
```

Arch Linux can install [kicad-pcb-diff](https://aur.archlinux.org/packages/kidiff) using the AUR repository:
Arch Linux can install
[kicad-pcb-diff](https://aur.archlinux.org/packages/kidiff) using the AUR
repository:

```bash
$ yay -S kidiff
Expand Down Expand Up @@ -113,8 +115,7 @@ $ git --no-pager diff XXXXXX.kicad_pcb
## PDF conversion policy

On some systems (i.e. Debian) ImageMagick disables PDF manipulation in its
*policy.xml* configuration file.
Comment or remove lines like this:
*policy.xml* configuration file. Comment or remove lines like this:

```
<policy domain="coder" rights="none" pattern="PDF" />
Expand All @@ -139,8 +140,9 @@ Shows a detailed list of the available options.

## --all_pages

Compare all pages for a schematic. Note that the tool doesn't currently support
adding or removing sheets, both documents must have the same ammount of pages.
Compare all pages for a schematic. Note that the tool doesn't currently
support adding or removing sheets, both documents must have the same amount of
pages.
## --cache_dir
Expand All @@ -151,11 +153,12 @@ PDFs.
## --diff_mode
Selects the mechanism used to represent the differences:
- **red_green** this is the default mode. Here we try to mimic the colored text
mode diff tools. Things added to the *old* file are reprsented in green and
things removed in red.
- **red_green** this is the default mode. Here we try to mimic the colored
text mode diff tools. Things added to the *old* file are represented in
green and things removed in red.
- **stats** in this mode all difference are represented in red. We compute the
ammount of pixels that are different, you can use this value to determine if
amount of pixels that are different, you can use this value to determine if
the changes are significant. See the `--fuzz` and `--threshold` options.
## --exclude
Expand Down Expand Up @@ -201,14 +204,14 @@ the colors. Enlarge it if you want to ignore bigger differences in the colors.

## --keep_pngs

Don't remove the individual PNGs. Complements `--output_dir`.
They are usually removed as soon as we get the output PDF.
Don't remove the individual PNGs. Complements `--output_dir`. They are usually
removed as soon as we get the output PDF.
## --layers
Specifies the name of a file containing a list of layers to be included.
This option works similar to `--exclude` but we process only the layers
indicated here.
Specifies the name of a file containing a list of layers to be included. This
option works similar to `--exclude` but we process only the layers indicated
here.
Important: when this list is only composed by layer numbers KiDiff skips any
check and uses this list of layers, even if they aren't defined in any of the
Expand Down Expand Up @@ -239,8 +242,8 @@ file.

## --output_dir

Five seconds after invoking the PDF viewer the output files are removed. If you
want to keep them for later review, or five seconds isn't enough for your
Five seconds after invoking the PDF viewer the output files are removed. If
you want to keep them for later review, or five seconds isn't enough for your
system, you can specify a directory to store the generated files.
Note: individual PNGs are always removed, consult `--keep_pngs`
Expand All @@ -266,9 +269,9 @@ Consult ImageMagick documentation in order to increase them.
## --threshold
In the *stats* mode this option can make KiDiff to return an error value if the
difference is bigger than the specified threshold. Indicating 0 means that we
don't look for errors, KiDiff always returns 0.
In the *stats* mode this option can make KiDiff to return an error value if
the difference is bigger than the specified threshold. Indicating 0 means that
we don't look for errors, KiDiff always returns 0.

## -v/--verbose

Expand All @@ -290,20 +293,21 @@ must specify a valid `cache_dir`. You should also take note of the hash used
by `kicad-diff.py`, or just provide one using the `--old_file_hash`.
You can then compare two files using the cached images, you just need to
provide the hashes you want to compare. The *old_file* and *new_file* won't
be used.
provide the hashes you want to compare. The *old_file* and *new_file* won't be
used.

# Similar tools

## KiCad-Diff

[KiCad-Diff](https://github.com/Gasman2014/KiCad-Diff) is a diff tool for PCBs,
is more oriented to GUI use. It has support not only for `git` but also for
`fossil` and `svn`. You can navigate the diffs and get information about added
or removed items, all using a browser. And is fast (all is handled using SVGs).
[KiCad-Diff](https://github.com/Gasman2014/KiCad-Diff) is a diff tool for
PCBs, is more oriented to GUI use. It has support not only for `git` but also
for `fossil` and `svn`. You can navigate the diffs and get information about
added or removed items, all using a browser. And is fast (all is handled using
SVGs).

It doesn't support schematics, can't be directly used as a git plug-in
(perhaps using some wrapper), can't meassure the ammout of difference and
(perhaps using some wrapper), can't measure the ammout of difference and
doesn't generate a file to see the differences (only browsable).

# Credits and notes
Expand Down
7 changes: 3 additions & 4 deletions kicad-diff-init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2022 Salvador E. Tropea
# Copyright (c) 2020-2022 Instituto Nacional de Tecnologïa Industrial
# Copyright (c) 2020-2022 Instituto Nacional de Tecnología Industrial
# License: GPL-2.0
# Project: KiCad Diff
"""
Expand Down Expand Up @@ -41,7 +40,7 @@ def CheckAttributes():
if not isfile(git_attributes):
logger.debug('No '+git_attributes)
return False
with open(git_attributes, "r") as attr_file:
with open(git_attributes) as attr_file:
for line in attr_file:
if re.match(r'^\*.kicad_pcb\s+diff', line):
attr_file.close()
Expand All @@ -53,7 +52,7 @@ def CheckCommand():
if not isfile(git_config):
logger.debug('No '+git_config)
return False
with open(git_config, "r") as cfg_file:
with open(git_config) as cfg_file:
for line in cfg_file:
if re.match(r'^\[diff\s+\"kicad_diff\"', line):
cfg_file.close()
Expand Down
7 changes: 3 additions & 4 deletions kicad-diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2023 Salvador E. Tropea
# Copyright (c) 2020-2023 Instituto Nacional de Tecnologïa Industrial
# License: GPL-2.0
Expand All @@ -18,7 +17,7 @@
specifying a cache directory and keep the resulting diff images specifying an
output directory.
The default resolution for the images is 150 DPI. It can be increased for
better images, at the cost of (exponetially) longer execution times. You can
better images, at the cost of (exponentially) longer execution times. You can
provide a smaller resolution for faster processing. For high resolution you
could need to configure the ImageMagick limits. Consult the 'identify -list
resource' command.
Expand Down Expand Up @@ -634,7 +633,7 @@ def load_layers_from_pcb(pcb_file, layers_file, kiri_mode):
name_to_id = {}
all_layers = []
logger.debug('Loading layers from PCB '+pcb_file)
with open(pcb_file, "r") as file_file:
with open(pcb_file) as file_file:
collect_layers = False
re_layer = re.compile(r'\s+\((\d+)\s+(\S+)')
re_layer_user = re.compile(r'\s+\((\d+)\s+(\S+)\s+user\s+"([^"]+)"')
Expand Down Expand Up @@ -700,7 +699,7 @@ def thre_type(astr, min=0, max=1e6):
if min <= value <= max:
return value
else:
raise argparse.ArgumentTypeError('value not in range %s-%s' % (min, max))
raise argparse.ArgumentTypeError('value not in range {}-{}'.format(min, max))


def get_layer(line):
Expand Down
1 change: 0 additions & 1 deletion kicad-git-diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2022 Salvador E. Tropea
# Copyright (c) 2020-2022 Instituto Nacional de Tecnologïa Industrial
# License: GPL-2.0
Expand Down
1 change: 0 additions & 1 deletion tests/test_pcb_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2022 Salvador E. Tropea
# Copyright (c) 2022 Instituto Nacional de Tecnologïa Industrial
# License: GPL-2.0
Expand Down
1 change: 0 additions & 1 deletion tests/test_sch_diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2022 Salvador E. Tropea
# Copyright (c) 2022 Instituto Nacional de Tecnologïa Industrial
# License: GPL-2.0
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def compare_pdf(self, gen, reference=None, diff='diff-{}.png'):
self.get_out_path(gen),
self.get_out_path('gen-%d.png')]
subprocess.check_call(cmd)
# Chek number of pages
# Check number of pages
ref_pages = glob(self.get_out_path('ref-*.png'))
gen_pages = glob(self.get_out_path('gen-*.png'))
logging.debug('Pages {} vs {}'.format(len(gen_pages), len(ref_pages)))
Expand Down Expand Up @@ -381,7 +381,7 @@ def filter_txt(self, file, pattern, repl):

@contextmanager
def start_kicad(self, cmd, cfg):
""" Context manager to run a command under a virual X server.
""" Context manager to run a command under a virtual X server.
Use like this: with context.start_kicad('command'): """
with recorded_xvfb(cfg):
if isinstance(cmd, str):
Expand Down

0 comments on commit 437141f

Please sign in to comment.