From 43d28326ad59c74439b96343cc8f619ed7d90231 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 26 Jan 2021 19:11:14 -0400 Subject: Made the Python being generated more compatible with both P2.7 and P3. --- .../source/program/aedifex/artifact/snapshot.lux | 72 ++++++++++++++++++++++ .../program/aedifex/artifact/snapshot/stamp.lux | 19 +++--- 2 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 stdlib/source/program/aedifex/artifact/snapshot.lux (limited to 'stdlib/source/program') diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux new file mode 100644 index 000000000..0488d76dd --- /dev/null +++ b/stdlib/source/program/aedifex/artifact/snapshot.lux @@ -0,0 +1,72 @@ +(.module: + [lux (#- Name Type) + [abstract + [equivalence (#+ Equivalence)] + [monad (#+ do)]] + [control + ["<>" parser + ["<.>" xml (#+ Parser)] + ["<.>" text]]] + [data + ["." sum] + [format + ["." xml (#+ XML)]]]] + ["." / #_ + ["#." stamp (#+ Stamp)]]) + +(type: #export Snapshot + #Local + (#Remote Stamp)) + +(structure: any_equivalence + (Equivalence Any) + + (def: (= _ _) + true)) + +(def: #export equivalence + (Equivalence Snapshot) + ($_ sum.equivalence + ..any_equivalence + /stamp.equivalence + )) + +(template [ ] + [(def: xml.Tag ["" ])] + + [ "localCopy"] + [ "snapshot"] + ) + +(def: local_copy_value + "true") + +(def: local_copy_format + XML + (#xml.Node + xml.attributes + (list (#xml.Text ..local_copy_value)))) + +(def: local_copy_parser + (Parser Any) + (do <>.monad + [_ (.node ..)] + (.children (.embed (.this ..local_copy_value) + .text)))) + +(def: #export (format snapshot) + (-> Snapshot XML) + (<| (#xml.Node .. xml.attributes) + (case snapshot + #Local + (list ..local_copy_format) + + (#Remote stamp) + (/stamp.format stamp)))) + +(def: #export parser + (Parser Snapshot) + (do <>.monad + [_ (.node )] + (.children (<>.or ..local_copy_parser + /stamp.parser)))) diff --git a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux index c1efcc8ee..ca59b11a6 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux @@ -1,11 +1,16 @@ (.module: [lux #* [abstract - [equivalence (#+ Equivalence)]] + [equivalence (#+ Equivalence)] + [monad (#+ do)]] + [control + ["<>" parser + ["<.>" xml (#+ Parser)] + ["<.>" text]]] [data ["." product] [format - [xml (#+ XML)]]]] + ["." xml (#+ XML)]]]] ["." // #_ ["#." time (#+ Time)] ["#." build (#+ Build)]]) @@ -21,22 +26,22 @@ //build.equivalence )) +(def: + xml.Tag + ["" "timestamp"]) + (def: time_format (-> Time XML) (|>> //time.format #xml.Text list - (#xml.Node ..tag xml.attributes))) + (#xml.Node .. xml.attributes))) (def: #export (format (^slots [#time #build])) (-> Stamp (List XML)) (list (..time_format time) (//build.format build))) -(def: - xml.Tag - ["" "timestamp"]) - ## (exception: #export (mismatch {expected Instant} {actual Instant}) ## (exception.report ## ["Expected" (%.instant expected)] -- cgit v1.2.3