summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-08-10 18:03:32 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commitb171ac5050d0118e58a465253d5d6cd23147ccfb (patch)
treeef992c4ca1b38896ed0faf41cd56e9da75c552b9
parent573a2612dc4d2bee77c673ceafb4f7d6e7482501 (diff)
downloadspack-b171ac5050d0118e58a465253d5d6cd23147ccfb.tar.gz
spack-b171ac5050d0118e58a465253d5d6cd23147ccfb.tar.bz2
spack-b171ac5050d0118e58a465253d5d6cd23147ccfb.tar.xz
spack-b171ac5050d0118e58a465253d5d6cd23147ccfb.zip
concretizer: split long lines in ASP programs
-rw-r--r--lib/spack/spack/solver/asp.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index a13f022a91..1380675dd9 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -25,6 +25,10 @@ from spack.util.executable import which
from spack.version import ver
+#: max line length for ASP programs in characters
+_max_line = 80
+
+
def _id(thing):
"""Quote string if needed for it to be a valid identifier."""
return '"%s"' % str(thing)
@@ -137,7 +141,10 @@ class AspGenerator(object):
def rule(self, head, body):
"""ASP rule (an implication)."""
- self.out.write("%s :- %s.\n" % (head, body))
+ rule_line = "%s :- %s.\n" % (head, body)
+ if len(rule_line) > _max_line:
+ rule_line = re.sub(r' \| ', "\n| ", rule_line)
+ self.out.write(rule_line)
def constraint(self, body):
"""ASP integrity constraint (rule with no head; can't be true)."""