Skip to content

Commit

Permalink
Add Kicad file support to automtime & autodescribe
Browse files Browse the repository at this point in the history
  • Loading branch information
dfandrich committed Apr 19, 2024
1 parent b988a74 commit ed7d96a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions autodescribe
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ comment_ebook() {
fi
}

# File type: kicad (Kicad schematic)
comment_kicad () {
COMMENT=$(sed -n -e '1,/(title_block/d' -e 's/^[[:space:]]*(title "\(.*\)")$/\1/p' -e '/^[[:space:]]*)$/,$d' < "$1")
}

# File type: kra (Krita image)
# requires: unzip, xmlstarlet
comment_kra () {
Expand Down Expand Up @@ -1518,6 +1523,8 @@ for f in "$@" ; do
;;
*.rss | *.atom) TYPE=rss
;;
*.kicad_sch | *.kicad_pcb) TYPE=kicad
;;
*.sla) TYPE=sla
;;
*.slob) TYPE=slob
Expand Down
10 changes: 10 additions & 0 deletions automtime
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ mtime_jpeg () {
TIME=$(echo "$RAWTIME" | sed -E -e 's/^([0-9][0-9][0-9][0-9]):([0-9][0-9]):/\1-\2-/')
}

# File type: kicad (Kicad schematic)
mtime_kicad () {
RAWTIME=$(sed -n -e '1,/(title_block/d' -e 's/^[[:space:]]*(date "\(.*\)")$/\1/p' -e '/^[[:space:]]*)$/,$d' < "$1")
# $RAWTIME is like 2021-01-03
TIME=$(normalize_time "$RAWTIME")
}

# File type: kra (Krita image)
# requires: unzip, xmlstarlet
mtime_kra () {
Expand Down Expand Up @@ -1028,6 +1035,9 @@ for f in "$@" ; do
TYPE=jpeg
;;

*.kicad_sch | *.kicad_pcb) TYPE=kicad
;;

*.kra)
TYPE=kra
;;
Expand Down
1 change: 1 addition & 0 deletions test-autodescribe-expected
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'testfiles/type1.jar' 'Jar Application Name'
'testfiles/type1.jpg' 'JPEG comment'
'testfiles/type1.kdenlive' 'Project Title'
'testfiles/type1.kicad_sch' 'Schematic Title'
'testfiles/type1.kra' 'Krita name'
'testfiles/type1.lsm' 'LSM Title'
'testfiles/type1.lzh' 'LZH comment in desc.sdi file'
Expand Down
1 change: 1 addition & 0 deletions test-automtime-expected
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'testfiles/type1.ics' '2022-02-05 20:25:32 +0000'
'testfiles/type1.iso' '2023-06-08 20:22:22.85 -0700'
'testfiles/type1.jar' '2023-04-06 22:34:26'
'testfiles/type1.kicad_sch' '2024-03-04 00:00:00'
'testfiles/type1.kra' '2022-01-01 13:57:46'
'testfiles/type1.lzh' '2021-10-15 06:09:47'
'testfiles/type1.lzo' '2021-10-12 03:50:26'
Expand Down
21 changes: 21 additions & 0 deletions testfiles/type1.kicad_sch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(kicad_sch (version 20230121) (generator eeschema)
(uuid 8143e87a-de44-4c51-98a1-364cce7810db)
(paper "A4")
(title_block
(title "Schematic Title")
(date "2024-03-04")
(rev "1")
(comment 1 "Schematic comment")
)
(lib_symbols
)
(sheet_instances
(path "/" (page "1"))
)
)

0 comments on commit ed7d96a

Please sign in to comment.