control: tags -1 patch

Hi,

there are basically only 2 python scripts included,
src/battery-stats-generate and src/battery-stats-graph.
Attached is a patch that adds a patch to d/patches to modify those for
python3 and also updates d/control & d/rules accordingly.

Cheers,
Birger
From 5c5e08d979559a91ea6e894d91c599fc229077f5 Mon Sep 17 00:00:00 2001
From: Birger Schacht <bir...@rantanplan.org>
Date: Mon, 27 Apr 2020 14:57:10 +0200
Subject: [PATCH] Update to python3

---
 debian/control                              | 11 ++--
 debian/patches/0001-Update-to-python3.patch | 56 +++++++++++++++++++++
 debian/patches/series                       |  1 +
 debian/rules                                |  2 +-
 4 files changed, 63 insertions(+), 7 deletions(-)
 create mode 100644 debian/patches/0001-Update-to-python3.patch
 create mode 100644 debian/patches/series

diff --git a/debian/control b/debian/control
index 4508933..9619c4e 100644
--- a/debian/control
+++ b/debian/control
@@ -5,26 +5,25 @@ Maintainer: Petter Reinholdtsen <p...@debian.org>
 Build-Depends:
  debhelper (>= 9),
  cmake,
- python | python-all | python-dev | python-all-dev,
+ python3 | python3-all | python3-dev | python3-all-dev,
  dh-python,
  gnuplot-nox (>= 4) | gnuplot-qt,
- python-matplotlib,
+ python3-matplotlib,
  libtext-csv-perl,
  imagemagick
 Standards-Version: 3.9.8
 Homepage: https://github.com/petterreinholdtsen/battery-stats/
 Vcs-Browser: https://anonscm.debian.org/gitweb/?p=collab-maint/battery-stats.git
 Vcs-Git: https://anonscm.debian.org/git/collab-maint/battery-stats.git
-X-Python-Version: >= 2.5
 
 Package: battery-stats
 Architecture: linux-any
 Depends: ${shlibs:Depends}, ${misc:Depends},
  logrotate,
  gzip (>= 1.3.2)
-Recommends: ${python:Depends},
- python,
- python-matplotlib,
+Recommends: ${python3:Depends},
+ python3,
+ python3-matplotlib,
  libtext-csv-perl,
  gnuplot (>= 4.0.0)
 Description: collects statistics about charge of laptop batteries
diff --git a/debian/patches/0001-Update-to-python3.patch b/debian/patches/0001-Update-to-python3.patch
new file mode 100644
index 0000000..e718fe7
--- /dev/null
+++ b/debian/patches/0001-Update-to-python3.patch
@@ -0,0 +1,56 @@
+From c1de7d133a9796d1825d6cc49a53f20bdf42f87d Mon Sep 17 00:00:00 2001
+From: Birger Schacht <bir...@rantanplan.org>
+Date: Mon, 27 Apr 2020 14:55:22 +0200
+Subject: [PATCH] Update to python3
+
+---
+ src/battery-stats-generate | 6 +++---
+ src/battery-stats-graph    | 4 ++--
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/battery-stats-generate b/src/battery-stats-generate
+index 7eab7c5..573a88d 100755
+--- a/src/battery-stats-generate
++++ b/src/battery-stats-generate
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+ 
+ import argparse
+ import itertools
+@@ -32,11 +32,11 @@ def generate(args):
+         print(','.join(fields))
+         # remove or add between 0 and 10% of the charge, half the time
+         energy_now += change_charge(args.discharge_prob,
+-                                    factor=random.randint(0, energy_full/args.discharge_rate))
++                                    factor=random.randint(0, int(energy_full/args.discharge_rate)))
+ 
+         # around one out of 3 changes to remove around 0.1% of charge
+         energy_full -= change_charge(args.damage_prob, mult = 0,
+-                                     factor=random.randint(0, energy_full/args.damage_rate))
++                                     factor=random.randint(0, int(energy_full/args.damage_rate)))
+         now += args.wait
+         if not i:
+             break
+diff --git a/src/battery-stats-graph b/src/battery-stats-graph
+index 2e651e4..8545048 100755
+--- a/src/battery-stats-graph
++++ b/src/battery-stats-graph
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ #
+ # This file is part of the battery-stats package.
+@@ -87,7 +87,7 @@ def parse_csv_builtin(fields =
+     except csv.Error as e:
+         logging.warning('CSV file is corrupt, skipping remaining entries: %s', e)
+     logging.debug('building data array')
+-    return np.array(data, dtype=zip(fields, 'f'*len(fields)))
++    return np.array(data, dtype=list(zip(fields, 'f'*len(fields))))
+ 
+ # the builtin CSV parser above is faster, we went from 8 to 2 seconds
+ # on our test data here there are probably other ways of making this
+-- 
+2.26.2
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..b8645f5
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-Update-to-python3.patch
diff --git a/debian/rules b/debian/rules
index 4647c9c..25115de 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,4 +1,4 @@
 #!/usr/bin/make -f
 
 %:
-	dh $@ --with python2
+	dh $@ --with python3
-- 
2.26.2

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to