<commit_before>// This file is part of Monsti, a web content management system.
// Copyright 2012-2013 <NAME>
//
// Monsti is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// Monsti is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Monsti.  If not, see <http://www.gnu.org/licenses/>.

package service

import (
	"encoding/json"
	"fmt"
	"reflect"
	"strings"
)

// DataClient represents the RPC connection to the Data service.
type DataClient struct {
	*Client
}

// NewDataClient returns a new Data Client.
func NewDataClient() *DataClient {
	var service_ DataClient
	service_.Client = new(Client)
	return &service_
}

// GetNode returns the given node or nil if it does not exist.
func (s *DataClient) GetNode(site, path string) (*NodeFields, error) {
	if s.Error != nil {
		return nil, s.Error
	}
	args := struct{ Site, Path string }{site, path}
	var reply []byte
	err := s.RPCClient.Call("Data.GetNode", args, &reply)
	if err != nil {
		return nil, fmt.Errorf("service: GetNode error: %v", err)
	}
	node := &NodeFields{}
	err = json.Unmarshal(reply, node)
	if err != nil {
		return nil, fmt.Errorf("service: Could not decode node: %v", err)
	}
	return node, nil
}

// lowerCaseEqualTo returns a function that checks for lowercase
// equality with the given value.
func lowerCaseEqualTo(value string) func(string) bool {
	return func(name string) bool {
		if strings.ToLower(name) == strings.ToLower(value) {
			return true
		}
		return false
	}
}

// nodeToData creates JSON data for the given field namespaces of the node.
func nodeToData(node interface{}, namespaces []string) ([][]byte, error) {
	nodeType := reflect.TypeOf(node)
	nodeValue := reflect.ValueOf(node)
	if nodeType.Kind() == reflect.Ptr {
		nodeType = nodeType.Elem()
		nodeValue = nodeValue.Elem()
	}
	if nodeType.Kind() != reflect.Struct {
		return nil, fmt.Errorf(
			"service: Node must be a struct or a pointer to a struct")
	}<commit_msg>Remove GetNode.<commit_after>// This file is part of Monsti, a web content management system.
// Copyright 2012-2013 <NAME>
//
// Monsti is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// Monsti is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Monsti.  If not, see <http://www.gnu.org/licenses/>.

package service

import (
	"encoding/json"
	"fmt"
	"reflect"
	"strings"
)

// DataClient represents the RPC connection to the Data service.
type DataClient struct {
	*Client
}

// NewDataClient returns a new Data Client.
func NewDataClient() *DataClient {
	var service_ DataClient
	service_.Client = new(Client)
	return &service_
}

// lowerCaseEqualTo returns a function that checks for lowercase
// equality with the given value.
func lowerCaseEqualTo(value string) func(string) bool {
	return func(name string) bool {
		if strings.ToLower(name) == strings.ToLower(value) {
			return true
		}
		return false
	}
}

// nodeToData creates JSON data for the given field namespaces of the node.
func nodeToData(node interface{}, namespaces []string) ([][]byte, error) {
	nodeType := reflect.TypeOf(node)
	nodeValue := reflect.ValueOf(node)
	if nodeType.Kind() == reflect.Ptr {
		nodeType = nodeType.Elem()
		nodeValue = nodeValue.Elem()
	}
	if nodeType.Kind() != reflect.Struct {
		return nil, fmt.Errorf(
			"service: Node must be a struct or a pointer to a struct")
	}
{'fraction_non_alphanumeric': 0.1024793388429752, 'fraction_numerical': 0.004250295159386069, 'mean_word_length': 3.7864406779661017, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6006610', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1236, 'n_words': 525}