File: pdfjs_generate_resource.py

package info (click to toggle)
epiphany-browser 3.38.2-1%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 27,476 kB
  • sloc: ansic: 65,045; javascript: 65,029; xml: 1,000; python: 163; sh: 82; makefile: 14
file content (26 lines) | stat: -rwxr-xr-x 773 bytes parent folder | download
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
"""
Pack pdf.js into a gresource file for Epiphany
"""

import os

def create_resource():
    """
    Traverse the current directory and add everything among the first level to the gresource file
    """
    resource = open('pdfjs.gresource.xml', 'w')
    resource.write('<?xml version="1.0" encoding="UTF-8"?>\n')
    resource.write('<gresources>\n')
    resource.write('\t<gresource prefix="/org/gnome/epiphany/pdfjs">\n')

    for root, _, files in os.walk("."):
        for file in files:
            if len(root) > 1:
                resource.write('\t\t<file compressed="true">' + root[2:] + '/' + file + '</file>\n')

    resource.write('\t</gresource>\n')
    resource.write('</gresources>\n')
    resource.close()

if __name__ == "__main__":
    create_resource()