-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #839 from camille-hdl/master
1.4.0 déplacer genreform physdesc
- Loading branch information
Showing
9 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "2" # required to adjust maintainability checks | ||
checks: | ||
argument-count: | ||
enabled: false | ||
complex-logic: | ||
config: | ||
threshold: 9 | ||
file-lines: | ||
config: | ||
threshold: 1000 | ||
method-complexity: | ||
config: | ||
threshold: 10 | ||
method-count: | ||
config: | ||
threshold: 20 | ||
method-lines: | ||
config: | ||
threshold: 250 | ||
nested-control-flow: | ||
config: | ||
threshold: 4 | ||
return-statements: | ||
enabled: false | ||
similar-code: | ||
config: | ||
threshold: 75 | ||
identical-code: | ||
config: | ||
threshold: 55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/lib/recipes/individual-recipes/deplacer-genreform-physdesc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//@flow | ||
import { xpathFilter } from "../../xml.js"; | ||
import { each } from "../utils.js"; | ||
import { last } from "ramda"; | ||
|
||
/** | ||
* Ligeo | ||
* Déplacer tous les //controlaccess/genreform dans physdesc. | ||
* C'est une version moins spécifique de ./corriger-genreform-physdesc.js | ||
*/ | ||
export default () => (doc: Document): Document => { | ||
const CAs = xpathFilter(doc, "//controlaccess"); | ||
each(CAs, (elem) => { | ||
const genreforms = xpathFilter(doc, elem, "genreform"); | ||
if (genreforms.length <= 0) return; | ||
const existingPhysdesc = last(xpathFilter(doc, elem, "(parent::c/did/physdesc)|(parent::archdesc/did/physdesc)")); | ||
const newPhysdesc = !existingPhysdesc; | ||
const physdesc = existingPhysdesc ? existingPhysdesc : doc.createElement("physdesc"); | ||
each(genreforms, (el) => { | ||
if (!el.hasAttribute("source")) { | ||
el.setAttribute("source", "genreform"); | ||
} | ||
if (!el.hasAttribute("type")) { | ||
el.setAttribute("type", "genre"); | ||
} | ||
physdesc.appendChild(el); | ||
}); | ||
if (newPhysdesc && physdesc.hasChildNodes()) { | ||
const did = last(xpathFilter(doc, elem, "(parent::c/did)|(parent::archdesc/did)")); | ||
if (!did) { | ||
console.log("Pas de did pour créer le physdesc."); | ||
return; | ||
} | ||
did.appendChild(physdesc); | ||
} | ||
}); | ||
return doc; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters