python-scala-libraries
БесплатноБез исполняемых скриптовНе проверенGuide for mapping common Python libraries and idioms to Scala equivalents. Use when converting Python code that uses standard library modules (json, datetime…
от benchflow-ai★ 1 941 звезда на GitHubОб этом скилле
Python to Scala Library Mappings
JSON Handling
# Python
import json
data = {"name": "Alice", "age": 30}
json_str = json.dumps(data)
parsed = json.loads(json_str)
# With dataclass
from dataclasses import dataclass, asdict
@dataclass
class Person:
name: str
age: int
person = Person("Alice", 30)
json.dumps(asdict(person))
// Scala - circe (most popular)
import io.circe._
import io.circe.generic.auto._
import io.circe.syntax._
import io.circe.parser._
case class Person(name: String, age: Int)
val person = Person("Alice", 30)
val jsonStr: String = person.asJson.noSpaces
val parsed: Either[Error, Person] = decode[Person](jsonStr)
// Scala - play-json
import play.api.libs.json._
case class Person(name: String, age: Int)
implicit val personFormat: Format[Person] = Json.format[Person]
val json = Json.toJson(person)
val parsed = json.as[Person]
Date and Time
# Python
from datetime import datetime, date, timedelta
import pytz
now = datetime.now()
today = date.today()
specific = datetime(2024, 1, 15, 10, 30)
formatted = now.strftime("%Y-%m-%d %H:%M:%S")
parsed = datetime.strptime("2024-01-15", "%Y-%m-%d")
tomorrow = now + timedelta(days=1)
# Timezone
utc_now = datetime.now(pytz.UTC)
// Scala - java.time (recommended)
import java.time._
import java.time.format.DateTimeFormatter
val now = LocalDateTime.now()
val today = LocalDate.now()
val specific = LocalDateTime.of(2024, 1, 15, 10, 30)
val formatted = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
val parsed = LocalDate.parse("2024-01-15")
val tomorrow = now.plusDays(1)
// Timezone
val utcNow = ZonedDateTime.now(ZoneOffset.UTC)
val instant = Instant.now()
File Operations
# Python
from pathlib import Path
import os
# Reading
with open("file.txt", "r") as f:
content = f.read()
lines = f.readlines()
# Writing
with open("file.txt", "w") as f:
f.write("Hello")
# Path operations
path = Path("dir/file.txt")
path.exists()
path.parent
path.name
path.suffix
list(Path(".").glob("*.txt"))
os.makedirs("new/dir", exist_ok=True)
// Scala - java.nio.file (standard) + scala.io
import java.nio.file.{Files, Path, Paths}
import scala.io.Source
import scala.util.Using
// Reading
val content = Source.fromFile("file.txt").mkString
Using(Source.fromFile("file.txt")) { source =>
source.getLines().toList
}
// Writing
Files.writeString(Paths.get("file.txt"), "Hello")
// Path operations
val path = Paths.get("dir/file.txt")
Files.exists(path)
path.getParent
path.getFileName
// Extension: path.toString.split('.').lastOption
Files.createDirectories(Paths.get("new/dir"))
// os-lib (better alternative)
// import os._
// os.read(os.pwd / "file.txt")
// os.write(os.pwd / "file.txt", "Hello")
Regular Expressions
# Python
import re
pattern = r"\d+"
text = "abc123def456"
# Search
match = re.search(pattern, text)
if match:
print(match.group())
# Find all
matches = re.findall(pattern, text)
# Replace
result = re.sub(pattern, "X", text)
# Split
parts = re.split(r"\s+", "a b c")
// Scala
val pattern = """\d+""".r
val text = "abc123def456"
// Search
pattern.findFirstIn(text) match {
case Some(m) => println(m)
case None => ()
}
// Find all
val matches = pattern.findAllIn(text).toList
// Replace
val result = pattern.replaceAllIn(text, "X")
// Split
val parts = """\s+""".r.split("a b c").toList
// Pattern matching with regex
val datePattern = """(\d{4})-(\d{2})-(\d{2})""".r
"2024-01-15" match {
case datePattern(year, month, day) => s"$year/$month/$day"
case _ => "no match"
}
HTTP Requests
# Python
import requests
response = requests.get("https://api.example.com/data")
data = response.json()
response = requests.post(
"https://api.example.com/data",
json={"key": "value"},
headers={"Authorization": "Bearer token"}
)
// Scala - sttp (recommended)
import sttp.client3._
import sttp.client3.circe._
import io.circe.generic.auto._
val backend = HttpURLConnectionBackend()
val response = basicRequest
.get(uri"https://api.example.com/data")
.send(backend)
val postResponse = basicRequest
.post(uri"https://api.example.com/data")
.body("""{"key": "value"}""")
.header("Authorization", "Bearer token")
.send(backend)
Logging
# Python
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.debug("Debug message")
logger.info("Info message")
logger.warning("Warning message")
logger.error("Error message", exc_info=True)
// Scala - scala-logging with logback
import com.typesafe.scalalogging.LazyLogging
class MyClass extends LazyLogging {
logger.debug("Debug message")
logger.info("Info message")
logger.warn("Warning message")
logger.error("Error message", exception)
}
// Alternative: slf4j directly
import org.slf4j.LoggerFactory
val logger = LoggerFactory.getLogger(getClass)
Установить python-scala-libraries в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл python-scala-libraries?
Guide for mapping common Python libraries and idioms to Scala equivalents. Use when converting Python code that uses standard library modules (json, datetime, os, re, logging) or needs equivalent Scala libraries for HTTP, testing, or async operations.
Как установить скилл python-scala-libraries?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python-scala-libraries запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic