[med-svn] [Git][med-team/ncbi-entrez-direct][upstream] New upstream version 19.2.20230331+dfsg

Aaron M. Ucko (@ucko) gitlab at salsa.debian.org
Fri Mar 31 22:55:35 BST 2023



Aaron M. Ucko pushed to branch upstream at Debian Med / ncbi-entrez-direct


Commits:
a0dd7d23 by Aaron M. Ucko at 2023-03-31T17:34:25-04:00
New upstream version 19.2.20230331+dfsg
- - - - -


3 changed files:

- eutils/misc.go
- eutils/xplore.go
- help/xtract-help.txt


Changes:

=====================================
eutils/misc.go
=====================================
@@ -2206,6 +2206,18 @@ func IsAllDigitsOrPeriod(str string) bool {
 	return true
 }
 
+// IsAllLettersOrDigits matches letters or digits
+func IsAllLettersOrDigits(str string) bool {
+
+	for _, ch := range str {
+		if !unicode.IsLetter(ch) && !unicode.IsDigit(ch) {
+			return false
+		}
+	}
+
+	return true
+}
+
 // IsNotASCII returns true for any character greater than 7-bits
 func IsNotASCII(str string) bool {
 


=====================================
eutils/xplore.go
=====================================
@@ -144,6 +144,11 @@ const (
 	TAB
 	RET
 	LBL
+	TAG
+	ATT
+	CLS
+	SLF
+	END
 	CLR
 	PFC
 	DEQ
@@ -429,6 +434,11 @@ var argTypeIs = map[string]ArgumentType{
 	"-tab":          CUSTOMIZATION,
 	"-ret":          CUSTOMIZATION,
 	"-lbl":          CUSTOMIZATION,
+	"-tag":          CUSTOMIZATION,
+	"-att":          CUSTOMIZATION,
+	"-cls":          CUSTOMIZATION,
+	"-slf":          CUSTOMIZATION,
+	"-end":          CUSTOMIZATION,
 	"-clr":          CUSTOMIZATION,
 	"-pfc":          CUSTOMIZATION,
 	"-deq":          CUSTOMIZATION,
@@ -503,6 +513,11 @@ var opTypeIs = map[string]OpType{
 	"-tab":          TAB,
 	"-ret":          RET,
 	"-lbl":          LBL,
+	"-tag":          TAG,
+	"-att":          ATT,
+	"-cls":          CLS,
+	"-slf":          SLF,
+	"-end":          END,
 	"-clr":          CLR,
 	"-pfc":          PFC,
 	"-deq":          DEQ,
@@ -1451,12 +1466,17 @@ func ParseArguments(cmdargs []string, pttrn string) *Block {
 				fmt.Fprintf(os.Stderr, "\nERROR: Unexpected position for %s command\n", txt)
 				os.Exit(1)
 			} else if txt == "-clr" {
-				// main loop runs out after trailing -clr, add another so this one will be executed
+				// main loop runs out after trailing -clr, add another one so this one will be executed
 				arguments = append(arguments, "-clr")
 				max++
+			} else if txt == "-cls" || txt == "-slf" {
+				// okay at end
 			} else if max < 2 || arguments[max-2] != "-lbl" {
 				fmt.Fprintf(os.Stderr, "\nERROR: Item missing after %s command\n", txt)
 				os.Exit(1)
+			} else if max < 3 || arguments[max-3] != "-att" {
+				fmt.Fprintf(os.Stderr, "\nERROR: Item missing after %s command\n", txt)
+				os.Exit(1)
 			}
 		}
 
@@ -1481,7 +1501,15 @@ func ParseArguments(cmdargs []string, pttrn string) *Block {
 				comm = append(comm, op)
 				status = UNSET
 			case ELEMENT:
-			case TAB, RET, PFX, SFX, SEP, LBL, PFC, DEQ, PLG, ELG, WRP, ENC, DEF, REG, EXP, COLOR:
+			case TAB, RET, PFX, SFX, SEP, LBL, TAG, ATT, END, PFC, DEQ, PLG, ELG, WRP, ENC, DEF, REG, EXP, COLOR:
+			case CLS:
+				op := &Operation{Type: LBL, Value: ">"}
+				comm = append(comm, op)
+				status = UNSET
+			case SLF:
+				op := &Operation{Type: LBL, Value: " />"}
+				comm = append(comm, op)
+				status = UNSET
 			case FWD, AWD, PKG:
 			case UNSET:
 				fmt.Fprintf(os.Stderr, "\nERROR: No -element before '%s'\n", str)
@@ -1676,6 +1704,24 @@ func ParseArguments(cmdargs []string, pttrn string) *Block {
 				op := &Operation{Type: status, Value: ConvertSlash(str)}
 				comm = append(comm, op)
 				status = UNSET
+			case TAG:
+				op := &Operation{Type: LBL, Value: "<" + ConvertSlash(str)}
+				comm = append(comm, op)
+				status = UNSET
+			case ATT:
+				op := &Operation{Type: LBL, Value: " " + ConvertSlash(str) + "="}
+				comm = append(comm, op)
+				if idx < max {
+					val := arguments[idx]
+					idx++
+					op := &Operation{Type: LBL, Value: "\"" + ConvertSlash(val) + "\""}
+					comm = append(comm, op)
+				}
+				status = UNSET
+			case END:
+				op := &Operation{Type: LBL, Value: "</" + ConvertSlash(str) + ">"}
+				comm = append(comm, op)
+				status = UNSET
 			case FWD:
 				cmds.Foreword = ConvertSlash(str)
 				status = UNSET
@@ -1841,6 +1887,7 @@ func ParseArguments(cmdargs []string, pttrn string) *Block {
 
 	// check for no -element or multiple -pattern commands
 	noElement := true
+	noClose := true
 	numPatterns := 0
 	for _, txt := range cmdargs {
 		if argTypeIs[txt] == EXTRACTION {
@@ -1851,6 +1898,8 @@ func ParseArguments(cmdargs []string, pttrn string) *Block {
 		} else if txt == "-select" {
 			noElement = false
 			head.Position = "select"
+		} else if txt == "-cls" || txt == "-slf" {
+			noClose = false
 		}
 	}
 
@@ -1864,7 +1913,7 @@ func ParseArguments(cmdargs []string, pttrn string) *Block {
 		os.Exit(1)
 	}
 
-	if noElement {
+	if noElement && noClose {
 		fmt.Fprintf(os.Stderr, "\nERROR: No -element statement in argument list\n")
 		os.Exit(1)
 	}
@@ -2310,7 +2359,27 @@ var (
 )
 
 // processClause handles comma-separated -element arguments
-func processClause(curr *XMLNode, stages []*Step, mask, prev, pfx, sfx, plg, sep, def, reg, exp string, wrp bool, status OpType, index, level int, variables map[string]string, transform map[string]string, srchr *FSMSearcher, histogram map[string]int) (string, bool) {
+func processClause(
+	curr *XMLNode,
+	stages []*Step,
+	mask string,
+	prev string,
+	pfx string,
+	sfx string,
+	plg string,
+	sep string,
+	def string,
+	reg string,
+	exp string,
+	wrp bool,
+	status OpType,
+	index int,
+	level int,
+	variables map[string]string,
+	transform map[string]string,
+	srchr *FSMSearcher,
+	histogram map[string]int,
+) (string, bool) {
 
 	if curr == nil || stages == nil {
 		return "", false
@@ -4661,7 +4730,20 @@ func processClause(curr *XMLNode, stages []*Step, mask, prev, pfx, sfx, plg, sep
 }
 
 // processInstructions performs extraction commands on a subset of XML
-func processInstructions(commands []*Operation, curr *XMLNode, mask, tab, ret string, index, level int, variables map[string]string, transform map[string]string, srchr *FSMSearcher, histogram map[string]int, accum func(string)) (string, string) {
+func processInstructions(
+	commands []*Operation,
+	curr *XMLNode,
+	mask string,
+	tab string,
+	ret string,
+	index int,
+	level int,
+	variables map[string]string,
+	transform map[string]string,
+	srchr *FSMSearcher,
+	histogram map[string]int,
+	accum func(string),
+) (string, string) {
 
 	if accum == nil {
 		return tab, ret
@@ -5433,7 +5515,19 @@ func conditionsAreSatisfied(conditions []*Operation, curr *XMLNode, mask string,
 // RECURSIVELY PROCESS EXPLORATION COMMANDS AND XML DATA STRUCTURE
 
 // processCommands visits XML nodes, performs conditional tests, and executes data extraction instructions
-func processCommands(cmds *Block, curr *XMLNode, tab, ret string, index, level int, variables map[string]string, transform map[string]string, srchr *FSMSearcher, histogram map[string]int, accum func(string)) (string, string) {
+func processCommands(
+	cmds *Block,
+	curr *XMLNode,
+	tab string,
+	ret string,
+	index int,
+	level int,
+	variables map[string]string,
+	transform map[string]string,
+	srchr *FSMSearcher,
+	histogram map[string]int,
+	accum func(string),
+) (string, string) {
 
 	if accum == nil {
 		return tab, ret


=====================================
help/xtract-help.txt
=====================================
@@ -114,6 +114,14 @@ XML Generation
   -fwd             Foreword to print before subset
   -awd             Afterword to print after subset
 
+Tag and Attribute Construction
+
+  -tag             Start with "<" + object name
+  -att             Attribute key and value
+  -cls             Close with ">"
+  -slf             Self-close with " />"
+  -end             End contents with "</" + object name + ">"
+
 Element Selection
 
   -element         Print all items that match tag name
@@ -304,6 +312,19 @@ Summary
   -contour         Display XML paths to leaf nodes
                      [delimiter]
 
+Full Exploration Command Precedence
+
+  -pattern
+  -path
+  -division
+  -group
+  -branch
+  -block
+  -section
+  -subset
+  -unit
+  -element
+
 Documentation
 
   -help            Print this document



View it on GitLab: https://salsa.debian.org/med-team/ncbi-entrez-direct/-/commit/a0dd7d23e8fc932f290193a88979890f46d5293a

-- 
View it on GitLab: https://salsa.debian.org/med-team/ncbi-entrez-direct/-/commit/a0dd7d23e8fc932f290193a88979890f46d5293a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230331/ae14b618/attachment-0001.htm>


More information about the debian-med-commit mailing list