File: update_file_format.py

package info (click to toggle)
librepcb 1.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 58,484 kB
  • sloc: cpp: 267,986; python: 12,100; ansic: 6,899; xml: 234; sh: 215; makefile: 115; perl: 73
file content (48 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import subprocess

DATA_ROOT = os.path.dirname(os.path.realpath(__file__))
CLI_EXECUTABLE = sys.argv[1]


def find(suffix):
    result = []
    for root, dirnames, filenames in os.walk(DATA_ROOT):
        if root.endswith(suffix):
            result.append(root)
        for filename in filenames:
            if filename.endswith(suffix):
                result.append(os.path.join(root, filename))
    return set(result)


def update_libraries():
    for library in find('.lplib'):
        subprocess.check_call([
            CLI_EXECUTABLE,
            'open-library',
            '--all',
            '--save',
            library,
        ])


def update_projects():
    for project in find('.lpp'):
        subprocess.check_call([
            CLI_EXECUTABLE,
            'open-project',
            '--save',
            project,
        ])


if __name__ == "__main__":
    os.environ['LIBREPCB_DISABLE_UNSTABLE_WARNING'] = '1'
    os.environ['LIBREPCB_UPGRADE_UNSTABLE'] = '1'
    update_libraries()
    update_projects()