diff options
author | Norbert Preining <preining@logic.at> | 2017-11-14 01:55:52 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-11-14 01:55:52 +0000 |
commit | a8aab6a5879b5e2b6f0668647d1e90bdbff98cdb (patch) | |
tree | 78fc836c6766136b7f45bbf33d331916ebc68172 /Master/tlpkg/TeXLive/TLPDB.pm | |
parent | 30ec8ba376ce0f3583a35183357fdf318fc45608 (diff) |
TLPDB: factorize json code, tlmgr: json for option
git-svn-id: svn://tug.org/texlive/trunk@45791 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPDB.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLPDB.pm | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index b4e79bd8711..68644527b6b 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -496,12 +496,9 @@ sub as_json { return($ret); } -sub _as_json { +sub options_as_json { my $self = shift; die("calling _as_json on virtual is not supported!") if ($self->is_virtual); - my $ret = "{"; - # options - $ret .= '"options":'; my $opts = $self->options; for my $k (keys %TeXLive::TLConfig::TLPDBOptions) { if ($TeXLive::TLConfig::TLPDBOptions{$k}[0] =~ m/^n/) { @@ -519,8 +516,12 @@ sub _as_json { } # the last else is plain strings, nothing to do } - $ret .= TeXLive::TLUtils::encode_json($opts); - $ret .= ',"settings":'; + return(TeXLive::TLUtils::encode_json($opts)); +} + +sub settings_as_json { + my $self = shift; + die("calling _as_json on virtual is not supported!") if ($self->is_virtual); my $sets = $self->settings; for my $k (keys %TeXLive::TLConfig::TLPDBSettings) { if ($TeXLive::TLConfig::TLPDBSettings{$k} eq "b") { @@ -531,15 +532,31 @@ sub _as_json { } # else are strings } - $ret .= TeXLive::TLUtils::encode_json($sets); - $ret .= ',"configs":'; + return(TeXLive::TLUtils::encode_json($sets)); +} + +sub configs_as_json { + my $self = shift; + die("calling _as_json on virtual is not supported!") if ($self->is_virtual); my %cfgs; $cfgs{'container_split_src_files'} = ($self->config_src_container ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False()); $cfgs{'container_split_doc_files'} = ($self->config_doc_container ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False()); $cfgs{'container_format'} = $self->config_container_format; $cfgs{'release'} = $self->config_release; $cfgs{'minrelease'} = $self->config_minrelease; - $ret .= TeXLive::TLUtils::encode_json(\%cfgs); + return(TeXLive::TLUtils::encode_json(\%cfgs)); +} + +sub _as_json { + my $self = shift; + die("calling _as_json on virtual is not supported!") if ($self->is_virtual); + my $ret = "{"; + $ret .= '"options":'; + $ret .= $self->options_as_json(); + $ret .= ',"settings":'; + $ret .= $self->settings_as_json(); + $ret .= ',"configs":'; + $ret .= $self->configs_as_json(); $ret .= ',"tlpkgs": ['; my $first = 1; foreach (keys %{$self->{'tlps'}}) { |