File: edit_console_scripts.py

package info (click to toggle)
numpy 1%3A1.24.2-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 44,720 kB
  • sloc: ansic: 188,931; python: 156,261; asm: 111,405; javascript: 32,693; cpp: 14,210; f90: 755; sh: 638; fortran: 478; makefile: 292; sed: 140; perl: 34
file content (28 lines) | stat: -rwxr-xr-x 687 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
#!/usr/bin/python3
#
# Helper tool to add f2pyX.YY to `console_scripts` section in entry_points.txt
#
# it expects 3 positional arguments:
#
# 1. the path to the `entry_points.txt` script
# 2. the option name to set
# 3. the value associated with that option name

import configparser
import sys


class CaseSensitiveConfigParser(configparser.ConfigParser):
    optionxform = staticmethod(str)


entry_points = CaseSensitiveConfigParser()
entry_points.read_file(open(sys.argv[1]))

if (sys.argv[2], sys.argv[3]) not in entry_points.items('console_scripts'):
    entry_points.set('console_scripts', sys.argv[2], sys.argv[3])


with open(sys.argv[1], 'w') as f:
    entry_points.write(f)