Merge remote-tracking branch 'origin/main' into Onlinesync
This commit is contained in:
+4
-23
@@ -10,17 +10,12 @@ function Get-AllCodeServerPages!NAME! {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Resource,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$RootProperty,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$CacheKeyProperty = "conceptCodeId",
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[ScriptBlock]$Converter = ${function:ConvertFrom-CodeServerObject!NAME!},
|
||||
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[int]$PageSize = 500
|
||||
)
|
||||
@@ -32,7 +27,6 @@ function Get-AllCodeServerPages!NAME! {
|
||||
$cacheKey = $Resource.GetHashCode()
|
||||
$cache[$cacheKey] = @{}
|
||||
}
|
||||
|
||||
process {
|
||||
$currentPage = 0;
|
||||
$Global:debugOut = @()
|
||||
@@ -56,16 +50,12 @@ function Get-AllCodeServerPages!NAME! {
|
||||
$Global:cache[$cacheKey].Add($key, $codeObject.attributes)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
write-output $cache[$cacheKey].Values
|
||||
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -76,32 +66,25 @@ function Get-CodeServerObject!NAME! {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$conceptCodeId,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Resource,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$RootProperty,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$CacheKeyProperty = "conceptCodeId"
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
if ($null -eq $Global:cache) {
|
||||
$params = @{
|
||||
Resource = $Resource;
|
||||
RootProperty = $RootProperty;
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey("CacheKeyProperty")) {
|
||||
$params.Add("CacheKeyProperty", $CacheKeyProperty)
|
||||
}
|
||||
|
||||
[void](Get-AllCodeServerPages!NAME! @params)
|
||||
}
|
||||
|
||||
$cacheKey = $Resource.GetHashCode()
|
||||
}
|
||||
|
||||
@@ -109,9 +92,7 @@ function Get-CodeServerObject!NAME! {
|
||||
Write-Debug $cacheKey
|
||||
Write-Output $cache[$cacheKey][$conceptCodeId]
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -151,9 +132,7 @@ class CodeServer!NAME! {
|
||||
|
||||
}
|
||||
|
||||
Export-ModuleMember ConvertFrom-CodeServerObject!NAME!
|
||||
Export-ModuleMember Get-AllCodeServerPages!NAME!
|
||||
Export-ModuleMember Get-CodeServerObject!NAME!
|
||||
Export-ModuleMember ConvertFrom-CodeServerObject!NAME!, Get-AllCodeServerPages!NAME!,Get-CodeServerObject!NAME!
|
||||
"""
|
||||
|
||||
def define_maps(items: list[str]) -> str:
|
||||
@@ -171,10 +150,12 @@ def write_psm(name, items: list[str], filename: Path = Path("CodeServerConnector
|
||||
backup_filename = str(filename) + f".{datetime.now().strftime('%Y-%m-%d.%H%M%S')}.bak"
|
||||
shutil.copy2(filename, backup_filename)
|
||||
|
||||
output = get_all_code.replace("!NAME!", name)
|
||||
output = "# ------- BEGIN CODE BLOCK -------\n"
|
||||
output += get_all_code.replace("!NAME!", name)
|
||||
output += get_code.replace("!NAME!", name)
|
||||
output += convert_from.replace("!NAME!", name).replace("!MAPS!", define_maps(items))
|
||||
output += class_definition.replace("!NAME!", name).replace("!VARIABLES!", define_variables(items)).replace("!STRINGS!", define_strings(items))
|
||||
output += "# ------- END CODE BLOCK -------\n"
|
||||
with open(filename, "a", encoding="utf-8-sig") as f:
|
||||
f.write(output)
|
||||
pass
|
||||
Reference in New Issue
Block a user